Skip to main content

Full text of "Elektor Magazine"

See other formats


9 770268 451128 





0 


L 1 

[ • 


r. 

























Hr--". +* 








r 


Choke A Chicken 

GT-3095 £8.50 + post & packing 
Relieve stress with a bit of 
violence! This annoying chicken 
dances around and squawks. 

Funny for about one second! 

Grab him by the throat and 
he screams and gags. 

Funny forever! (not 
recommended for ^ 
children). Approx 12" ^ 
tall. Requires 4 x AA 
batteries (not ind.) 


1 





Theremin Synthesiser Kit 

KC-5295 £14.75 + post & packing 


The Theremin is 
a weird musical 
instrument that was 
invented early 
last century 
but is still 
used today. 

The Beach 
Boys' classic 
hit "Good 

Vibrations" featured 
aTheremin. By moving you hand 
between the antenna and the metal 
plate, you can create strange sound 
effects. Kit includes a machined, silk 
screened, and pre drilled case, circuit 
board, all electronic components, and 
clear English instructions. 

We Stock... 


Electronic Components, 
Sub-Assemblies & Electronic Kits 


Power Products 
& Accessories 


Audio 61 Visual Equipment 
& Accessories 


Computer 61 Telecoms 
Accessories 


Burglar Alarms 61 
Surveillance Equipment 


Lighting Products 
61 Accessories 


Gadgets 61 Unique Gifts 


tjfl 


Call or log on to our website and apply for a FREE 

400 page catalogue. You can purchase on the Net 

from us 24/7/365 through our secure encrypted 

system. Post and packing charges are modest and 

you can have any of 8000+ unique products 

delivered to your door within 

Smart Card Reader/ 7-10 days of your order. 

Programmer Kit 

KC-5361 £15.95 + post & packing 
Jaycar has noticed a substantial increase in sales of 
the KC-5361 Smart Card Programmer Kit & 

ZZ-8800 Programmable Gold Wafer Card. We 
strongly suspect that this maybe due to persons 
unknown some how using these products to make 
unlawfully generated access codes for the latest 
cable T.V. set top boxes. We also wish to advise 
that we discourage this activity. For those 
legitimate users, the KC-5361 
Programmer Kit £15.95 & 

ZZ-8800 Smart Card £3.85 
are back in stock. 

Once again please be 
reminded that we cannot 
accept any responsibility for 
the use of these devices in 
other than legitimate 
activities. 




Wafer Card 

ZZ-8800 £3.85 + post & packing 
This is a multi-chip 'smart card' based 
on the PIC 16F84A and is coupled 
with a 24LC16B EEPROM, 
compatible with most 
reader/programmer units 
available including the 
programmer above. 




"Clock Watcher's" LED Clock Kits 

KC-5416(blue) £55.25 + post & packing 

KC-5404(red) £41.35 + post & packing 

These clocks are hypnotic! 

They consist of an AVR driven clock circuit, that also 
produces a dazzling display with the 60 LEDs around the 
perimeter. It looks amazing, but can't be properly explained 
here. We have filmed it in action so you can see for yourself 
on our website www.jaycarelectonics.com! Kit supplied with 
double sided silkcreened plated through hole PCB and all 
board components 
as well as the 
special clock 
housing! 

Available 
in Blue 

(KC-5416) and 
Red (KC-5404). 



High Performance Electronic Projects for Cars 

BS-5080 £7.00 + post & packing 

Australia's leading electronics magazine Silicon Chip, has developed a range of projects for performance 
cars. There are 16 projects in total, ranging from devices for remapping fuel curves, to nitrous controllers. 
The book includes all instructions, components lists, color pictures, and circuit layouts. There are also 
chapters on engine management, advanced systems and DIY modifications. Over 150 pages! All the 
projects are available in kit form. 


Smart Fuel Mixture Display 

KC-5374 £8.95 + post & packing 
This new 'smart' version has a few additional touches 
such as, auto dimming for night driving, emergency 
lean-out alarm, and better circuit protection. Another 
great feature, is the 'dancing' display which operates 
when the ECU is operating in closed loop. Kit supplied 
with PCB and all electronic components. 

• Car must be fitted with air flow 
and EGO sensors (standard ^ 
on all EFI systems) 
for full 
functionality. 

Recommended box 
HB-6014 £1.40 each 



High Range Adjustable j 

Temperature Switch with LCD 

KC-5376 £22.75 + post & packing 
Heat can be a major problem with 
any car, especially modified and 
performance cars. The more power, 
the more heat, so you need to 
ensure you have adequate cooling 
systems in place. This temperature 
switch can be set anywhere up to 
2192°F, so it is extremely versatile. The 
relay can be used to trigger an extra 
thermo fan on an intercooler, mount a sensor 
near your turbo manifold and trigger water spray 
cooling, or a simple buzzer or light to warn you of a 
high temperature. The LCD displays the temperature 
all the time, which can easily be dash mounted. 



» Fausts 

m onrtor m 9 tore . 

**£?5*|r 



400+ page 
Catalogue 


aycar 


Post and Packing Charges: 
Order Value Cost 


£20 - £49.99 
£50 - £99.99 
£100 - £199.99 
£200 - £499.99 
£500+ 


Cost 

£5 

£10 

£20 

£30 

£40 


Max weight 121b (5kg) - heavier parcels POA. 
Minimum order £20. 


Log on to 

www.jaycarelectronics.co.uk/elektor 

for your FREE catalogue! 

0800 032 7241 

(Monday - Friday 09.00 to 17.30 GMT + 10 hours only). 
For those who want to write: 

100 Silverwater Rd Silverwater NSW 2128 
Sydney AUSTRALIA 




















FT232R usb uart with 

MCU Clock Generator and 
FTDIChip-ID™ Security Dongle 

A MORE 


Integration - EEPROM, internal clock generator, and 
USB termination resistors on-chip. 

Functionality - integrates the functions of USB UART, 
MCU clock generator and Security Dongle into a single 
chip. 

Flexibility - five 10 pins can each be user configured 
as Sleep, Transmit Enable, Power Enable, MCU Clock 
Output, TX/RX LED Drive or GPIO Pin 
Security - FTDIChip-ID™ technology helps protect 
your application software. 

I/O Drive Capability - from 5.5v down to 1 .8v levels at 
4mA or 12mA programmable strength. 

I/O Modes - synchronous and asynchronous Bit-Bang 
I/O 

OS Support - in house developed & supported drivers 
for Windows 98,ME,2K, Server 2003, XP, XP64, 
Embedded XP, Mac OS8,9,X, Linux, Win CE + many 
3rd party drivers. 

Driver Options - VCP and D2XX drivers for all 
Windows platforms and Linux. 

Technical Support - a wide range of evaluation kits 
available from the outset make evaluating the FT232R 
a snap. 

Package Choices - SSOP28 and QFN32 
Interface Options - also available with a parallel FIFO 
interface 
( p/n FT245R ). 








•* 











EVALUATION 


LESS 


External Components - no crystal, EEPROM or USB 
termination resistors required. 

Board Space - new QFN package takes up only 
25mm 2 of pcb area. 

Manufacturing Cost - minimal external component 
count coupled with competitive pricing reduces the 
overall cost. 

Programming - FT232R comes pre-programmed with 
each part having a unique USB serial number burnt in. 
This eliminates the need to program the EEPROM in 
many cases and saves on production time / cost. 

Time to Market - FT232R eliminates USB driver 
and firmware development in most cases 
thus significantly reducing 
time to market. 



FT232* 



Europe HQ 

Future Technology Devices International Ltd. 

373 Scotland Street, Tel. ; +(44) 141 429 2777 
Glasgow G5 8QB, Fax. : +(44) 141 429 2758 

United Kingdom E-Mail : sales1@ftdichip.com 



gboso 

cbus* 

GBUS2 



www.ftdichip.com 







Micros turn Mega 






acting the way 


I've always been confident that the Greek 
prefixes |j (micro) and M (mega) are 
safely apart at an immense factor of 1 0 1 2 
or one bin ion. The venerable prefixes are 
established in electronics to the extent that 
only rank beginners would surmise the 
existence of microhertz frequencies and 
megafarad capacitances. Sure, these 
exist in theory but no-one's ever seen the 
equipment or capacitor to match. 
Although it's not necessary right now to 
burn your maths textbooks, recently the 
distance between micro and mega has 
dwindled and in fact both prefixes can 
now be said to co-exist happily in two 
species of electronic component. The 
main subjects of this month's issue, 
microcontrollers and FPGAs, execute 
microinstructions from megabytes of 
memory, not forgetting nanosecond sig- 
nal setup times and several kilobits a sec- 
ond worth of data traffic on serial lines. 

If you thought that the microcontroller 
was the next and perhaps final step in 
an evolutionary process that started with 
the valve and went by way of the tran- 
sistor and the integrated circuit, buckle 
up for FPGAs. To illustrate the scale at 
which we need to think now, some 
FPGAs are powerful enough to mimic a 
vintage 6502 microprocessor including 
its exact pin functionality, and still have 
room to spare for 'side activities' like 
serial interfacing and memory flashing. 
Readers tell us that they find FPGAs 
impressive and even awe-inspiring, but 
also off putting not just for design com- 
plexity but mostly 'solderability'! 

Here at Elektor Electronics we're not in 
the least afraid to deal with the latest in 
FPGA and microcontroller land, witness 
our Versatile FPGA Module, FPGA Pro- 
totyping Board and Renesas R8C/13 
Motherboard. Let the professionals do 
the soldering — in all three cases we 
supply the boards with all the dreaded 
SMDs, BGAs and TQFPs and what have 
you ready fitted, so you can concentrate 
on the real thing: programming and 
developing turnkey applications with 
maximum intelligence and an absolute 
minimum of components. I wouldn't say 
wielding a full-blown FPGA or R8C 
development system is a micro effort at 
a nano investment but you can be cer- 
tain of mega results. Glad to help you. 

Jan Baiting 
Editor 


16 


Until recently, FPGAs were 
practically reserved for 
specialists in high-tech 
companies. That's all 
changed now thanks to low 
component prices and free 
design software, so it's high 
time to devote attention to 
this technology in Elektor 
Electronics. The FPGA 
module discussed in this 
article forms the core of 
various upcoming projects 
in the magazine. 

Versatile 


FPGA Modu 



Free C Booklet 



Th is issue comes with a free 24- 
page introduction to C pro- 
gramming. The booklet is not 
only a runway to an industry- 
standard programming lan- 
guage, but also a prelude 
to articles on C for our 
low-cost R8C Starter Kit. 

















CONTENTS 


Volume 32 
March 2006 
no. 352 



■t 

'*<* 

£ik 

00 

'll! 

$><$! 

(E 0 1 

*flP| 

i * 

0£ 

fUE 


« 1 


Ci 




*‘C 


f* 


i , 








We devote attention to interesting but affordable 
kits where we not only look at kits that are suitable 
for a commercial environment but which are also 
very interesting for hobby use. 


28 Development Kits 


38 Application Board for R8C/1 3 






Last month we described how you can get started with our 
under-£10 R8C/1 3 microcontroller module. The Now we 

add a 'base camp' with lots of con- 
nections to the outside world like 
USB, two serial ports and an 
LCD interface. 


know-how 


68 Linear Motors 


hands-on 


16 Versatile FPGA Module 
20 FPGA Prototyping Board 
38 Application Board for R8C/13 
46 Cheap Logger 
54 A real pC PLC 
63 Telephone Eavesdropper 
Design Tips 

Energy recovery 

FBI siren with flashing light 

Energy saver for relays 

Opamp with increased output current 


technology 


50 Travel Charger 
58 E-blocks Making Waves 


info & market 


6 Colophon 

8 Mailbox 

Corrections & Updates 

News & New Products 

28 Development Kits 

74 The 'Kaleidoscope' 
E-CAD DVD 

84 Sneak Preview 


infotainment 


34 The Triumphant March 
of the 6502 

Retronics: 

Elektor Plotters (1 988-1 991 ) 

79 Hexadoku (3) 




















lektor 

lectronics 

Volume 32, Number 352, March 2005 ISSN 0268/45 1 9 

Elektor Electronics aims at inspiring people to master electronics at any person- 
al level by presenting construction projects and spotting developments in elec- 
tronics and information technology. 

Publishers: Elektor Electronics (Publishing), Regus Brentford, 1000 Great West Road, 

Brentford TW8 9HH, England. Tel. (+44) (0) 208 261 4509, fax: (+44) (0) 208 261 4447 

www.elektor-electronics.co.uk. 

The magazine is available from newsagents, bookshops and electronics retail outlets, or on sub- 
scription. Elektor Electronics is published I I times a year with a double issue for July & August. 

Under the name Elektor and Elektuur, the magazine is also published in French, German and 
Dutch. Together with franchised editions the magazine is on circulation in more than 50 countries. 

International Editor: Mat Heffels (m.heffels@segment.nl) 

Editor: Jan Buiting (editor@elektor-electronics.co.uk) 

International editorial staff: Harry Baggen, Thijs Beckers, Ernst Krempelsauer, 

Jens Nickel, Guy Raedersdorf. 

Design staff: Ton Giesberts, Paul Goossens, Luc Lemmens, Karel Walraven 
Editorial secretariat: Hedwig Hennekens (secretariaat@segment.nl) 

Graphic design / DTP: Ton Gulikers, Giel Dols 

Managing Director / Publisher: Paul Snakkers 
Marketing: Margriet Debeij (m.debeij@segment.nl) 


Subscriptions: Elektor Electronics (Publishing), 

Regus Brentford, 1000 Great West Road, Brentford TW8 9HH, England. 

Tel. (+44) (0) 208 26 1 4509, fax: (+44) (0) 208 26 1 4447 

Internet: www.elektor-electronics.co.uk 

Email: subscriptions@elektor-electronics.co.uk 

Rates and terms are given on the Subscription Order Form 

Head Office: Segment b.v. RO. Box 75 NL-6I90-AB Beek The Netherlands 
Telephone: (+31)46 4389444, Fax: (+31)46 4370161 

Distribution: Seymour, 86 Newman Street, London Wl P 3LD, England 

UK Advertising: Huson International Media, Cambridge House, Gogmore Lane, 

Chertsey, Surrey KTI 6 9AR England. 

Telephone: +44 (0) 1 932 564999, Fax: +44 (0) I 932 564998 
Email: r.elgar@husonmedia.com 
Internet: www.husonmedia.com 
Advertising rates and terms available on request. 

International Advertising: Klaas Caldenhoven, address as Head Office 

Email: advertenties@elektuur.nl 

Advertising rates and terms available on request. 

Copyright Notice 

The circuits described in this magazine are for domestic use only. All drawings, photographs, printed circuit 
board layouts, programmed integrated circuits, disks, CD-ROMs, software carriers and article texts pub- 
lished in our books and magazines (other than third-party advertisements) are copyright Segment, b.v. and 
may not be reproduced or transmitted in any form or by any means, including photocopying, scanning an 
recording, in whole or in part without prior written permission from the Publishers. Such written permis- 
sion must also be obtained before any part of this publication is stored in a retrieval system of any nature. 
Patent protection may exist in respect of circuits, devices, components etc. described in this magazine. The 
Publisher does not accept responsibility for failing to identify such patent(s) or other protection. 

The submission of designs or articles implies permission to the Publishers to alter the text and design, and 
to use the contents in other Segment publications and activities. The Publishers cannot guarantee to return 
any material submitted to them. 

Disclaimer 

Prices and descriptions of publication-related items subject to change. Errors and omissions excluded. 

© Segment b.v. 2006 Printed in the Netherlands 




£ 

a> 



lectronics 


cd-rom Elektor 2005 

This CD-ROM contains all editorial 
articles, with the exception of New 
Products items, published in Elektor 
Electronics magazine Volume 2005. 

Using the supplied Acrobat Reader 
program, articles are presented in 
the same layout as originally found in the magazine. 

The DiskMirror utility on this CD-ROM allows your earlier Elektor 
year volume CD-ROMs (1997-2004) to be added to a large archive 
on hard disk for fast access and easy reference. 

A built-in search function allows you to find references in any article 
from the archive on hard disk, or from individual year volume 
CD-ROMs you have available. 



6 


elektor electronics - 3/2006 




SERIAL COMMUNICATIONS SPECIALISTS 

Test and Measurement Solutions 



featured products 


= = = Bronze Prize Winner = = 
NASA Tech Briefs 2004 
Products of the Year 



£125.00 


DS1 Ml 2 USB Scope / Logger 

2x1 MS/s Input Channels + waveform 
generator output. EasyScope & EasyLogger s/w 
included. 




Affordable CAN Bus Solutions 

CANUSB is a very small dongle that plugs into any PC USB Port 
and gives an instant CAN connectivity. This means it can be treated 
by software as a standard COM Port (serial RS232 port) which 
eliminates the need for any extra drivers or by installing a direct 
driver DLL for faster communications and higher CAN bus loads. 
CAN232 is a very small dongle that plugs into any PC COM Port, or 
any other RS232 port in an embedded system and gives an instant 
CAN connectivity. This means it can be treated by software as a 
standard COM Port (serial RS232 port) which eliminates the need 
for any extra drivers. Sending and receiving can be done in standard 
ASCII format. 

priced from £61 .00 (CAN-232) 


USB Instruments - PC Oscilloscopes & Logic Analyzers 

Our range of PC Instruments may be budget priced but have 
a wealth of features normally only found in more expensive 
instrumentation. Our DS1M12 and PS40M10 oscilloscopes have 
sophisticated digital triggering including delayed timebase and come 
with our EasyScope oscilloscope / spectrum analyzer / voltage 
and frequency display application software and our EasyLogger 
data logging software. We also provide Windows DLLs and code 
examples for 3rd party software interfacing to our scopes. 

OurANT8 and ANTI 6 Logic Analyzers feature 8/16 capture channels 
of data at a blazing 500MS/S sample rate in a compact enclosure. 

priced from £125.00 ( DS1M12 & ANT8 ) 




* 




£36.00 


USB-2C0M- 


2 Port Industrial USB RS232 Serial with wall 
mount bracket and DC auxiliary output 



1 to 16 port USB to Serial Adapters 

With over 16 different models available, we probably stock the 
widest range of USB Serial Adapters available anywhere. We offer 
converter cables, multi-port enclosure style models in metal and 
plastic, also rack mount units with integral PSU such as the USB- 
16COM-RM. Serial interfaces supported include RS232, RS422 and 
RS485. We also supply opto-isolated RS422 and RS485 versions for 
relaible long distance communications. All our USB Serial products 
are based on the premium chipsets and drivers from FTDI Chip for 
superior compatibility, performance and technical support across 
Windows, MAC-OS, CE and Linux platforms. 

priced from £20.00 ( US232B/LC ) 

UPCI Serial Cards 

Discover our great value for money range of multi-port UPCI serial 
cards. Supporting from two to eight ports, the range includes RS232, 
RS422, RS485 and opto-isolated versions. Our 4 port and 8 port 
models can connect through external cables or the innovative wall 
mounting COMBOX. 

priced from £21.00 ( UPCI - 200L ) 


EasySync Ltd 


373 Scotland Street 
Glasgow G5 8QB U.K. 

Tel: +44 (141)418-0181 Fax: +44 (141)418-0110 
Web : http://www.easysync.co.uk 
E-Mail: sales@easysync.co.uk 

Prices shown exclude carriage and VAT where applicable 


7 









INFO & MARKET 


MAILBOX 


Retronics 

on multimeters (3) 

Dear Sir — I enjoyed very 
much Jan Buiting's article on 
analogue multimeters 
('Retronics', December 2005, 
Ed.). I myself own an excel- 
lent BBC Goerz Unigor A43 
analogue multimeter that I 
bought at a flea market. It 
has a DC sensitivity of 
100 kohms/volt and its low- 
est DC current scale is 10 
microAmperes. 

In addition to the advantages 
of analogue over digital 
meters mentioned in the arti- 
cle, I would like to call your 
attention to another one men- 
tioned by Robert A. Pease in 
his book Troubleshooting 
Analog Circuits. On page 1 7 
he says: 



"Another advantage of ana- 
log meters is that they are 
passive devices: They don't 
inject noise into your circuit 
as digital meters can — even 
battery powered ones. And 
they have a lot less capaci- 
tance to ground". 

Mr. Pease is referring to the 
noise generated inside digital 
meters by the A/D conver- 
sion process, of course. 
Congratulations Jan for your 
interesting article. 

Carlos Urbina Pacheco 
(Mexico) 

Thanks for the compliment Car- 
los , as they say "it makes a wel- 
come change from being at the 
wrong end of the customer com- 
plaints line". The photograph 
shows an Unigor 4S meter from 
my collection. 




JWWUft \7~7 
\/ 


vl £.r L A7Vfi 


Vtvp.'T T 

TT 


r~ 


Battery backup for bike 
— help please 
(Mailbox December 2005 
issue refers, Ed.) 

Dear Editor — I have got my 
dynamo backup circuit to 
work: a voltage doubling rec- 
tifier solved the problem 
caused by the half-wave recti- 
fier's series capacitor. 

I enclose the corrected 
schematic. Note that the DC 
isolator capacitors are mount- 
ed separately beside the 
dynamo, whereas the circuit 
is mounted at the other end 
of the bike (near the battery 
pouch). 

The battery is also used for 
extra lamp(s) such as a turn 
indicator. 

The circuit seems to take 
3 mA from battery when 
switched over to dynamo but 
even if that's just noise 
picked up by the meter, I can 
live with it. 

I found the free Linear 
Technology LTSpice program 
very useful. 

An alternative circuit (simulat- 
ed with LTSpice) replaced the 
optoisolator and BJT with a 
logic-level p-channel MOSFET 
(protected by a zener), and 



connected battery ground to 
dynamo ground. 

Unfortunately, Maplin no 
longer sell p-type MOSFETs so 
I could not build this circuit. 

I have also enclosed a photo 
of the finished unit. The han- 
dlebar bracket is a Minoura 
battery lamp extension (long) 
minus the lamp tube. 

Alan Bradley (UK) 

That's a happy ending then Alan , 
congratulations on getting your 
circuit to work. We also thank 
those readers who have written 
with suggestions to help Alan find 
(and solve) the problem. He also 
informed us that he has further 
information available on the 
migration of the circuit to FETs. 


Hexadokus 

While compiling this month's 
Mailbox pages , we're inundated 
with solutions to our first and 
second ' Hexadoku ' puzzles 
published in the January I 
and February 2006 issue. I 
Apparently we succeeded I 
in adding a lighter note to I 
high-brow electronics stuff I 
that normally fills our I 
pages. We were both I 

pleased and surprised to I 

see that a good number I 
of correct solutions I 
were sent by family I 
members of our read- I 
ers. A number of I 
solutions reached us I 
by regular post I 
(thank you all for I 
using our new I 
address). Readers 
were also quick to 


spot that our Hexadokus can be 
downloaded free of charge from 
our website. Here's some com- 
ment we got from you: 

"A great opportunity for us 
lesser gods in electronics to 
win a prize". 

"Can we have a microcon- 
troller version of it please." 
"Took me two days to solve 
but I think I have the solution." 
"What a wonderful idea this 
Flexadoku; just what I would 
expect from Elektor." 

"I just love Sudokus and was 
hooked the moment my hus- 
band showed your hexadeci- 
mal variety. It's addictive and 
crazing. And tough, too." 
"The normal 9x9 Sudoku was 
starting to bore me. Your hex 
variety got my grey matter 
milling over numbers again." 
"A great puzzle. I was 
already hooked on Sudokus 
but yours is even worse!" 
"Cost me one pencil and a 
rubber to solve; 


8 


elektor electronics - 3/2006 



i Rejektor 

■ A power-wise server 

ADSL, wideband and fast 
cable Internet connections 
spreading very fast across 
countries in the world, 
many of you may start to 
I think about using an old 
I PC as a server. 

I Unfortunately many forget 
I the server's additional 
I power consumption adding 
considerably to the electric- 
ity bill. The average con- 
sumption of a Pentium 1 33 
. PC without a CRT monitor 
is between 50 and 100 
I watts. A Pentium P2-266 
I consumes even 25% more! 

I A typical CRT monitor will 
I consume 80 watts on aver- 
I age. Money-wise that's 
I about 60 pounds per year 
if the equipment is left on 
all the time. 

Mr Jeroen Baars from the 
Netherlands sent us his 
suggestions for reduced 
I power consumption for 
I small network servers, 

I based on his own experi- 
I ence with a Pentium 1 33 
I PC. The best candidates for 
this kind of server applica- 
tions are PCs with a CPU 
running at anywhere 
! between 90 and 233 MHz 
and having a Socket-7 type 
motherboard. Although a 
I Socket-5 or a 486 
I DX/DX2/DX4 may also be 
I suitable, these machines 
I will be found to be sluggish 
I and have somewhat higher 
I power consumption. 

To begin with you should 
® check if the PC is still fully 
functional. Run a thorough 
test on the hard disk, then 
make sure it's virus-free. 

■ Make notes of the hard- 


Under this heading we will occasionally publish circuits, ideas and 

suggestions that did not make it to full publication in this magazine for various reasons (like lack of space). 


HEM ] Efl I EDS NitlETEMJ 
riMtH mnnbCjrlEifT U W 
ittaiEi ih,- 



liq 4 ittto iJ i Xpiihlp 

IRQ 5 CUT Up LftH < Instils 
b (fivww Phiv- tl^hln 
I FU ? CUT He LrtH i . run Ur 

!H ft ■ tut Up 

IRQ 9 CP-cvo-vt:!? n Ihi.blo 
I HU - r^hln 

J HD II Efeirrvcaj i Inn Mb 
m (5 j 2 

IF.'J LI uni I E-Mbl-B 

!• U h Pi Shi ! MtJr 

1ED 1*. i !■ F Friffi J : luhlfi 


i Uu I L tl- : Hew 

i lie Em mr***f- : IHM lfi(. 

i Mrl UUuc-a: fRH it L Itt : Hu I nr 
10 ■ Ln».I CTUK prf # qjl¥ 

- Lmi KnLup FcFmEIi 


ware address and IRQ of the 
network card. Next you can 
disassemble the PC to pre- 
pare it for its future function. 
Open up the power supply 
and remove dust and dirt 
with a small brush. Watch 
out for residual charge of the 
electrolytic capacitors. 
Connect the fan to 5 V 
instead of 1 2 V and check it 
runs smoothly and reliably on 
the lower voltage. If not, 
replace it by one that does. 
Replace the CPU cooler by a 
version without a fan. In most 
cases the fan can be 
removed from the heatsink 
and the cooling will still be 
sufficient. Replace a high-per- 
formance video card you 
may come across by a stan- 
dard card with just 1 , 2 or 4 
Mbytes of memory. If an ISA 
card is used, make sure the 
hardware address and IRQs 
are known (for the software 
installation). A PCI card will 
usually stand a higher 
chance of success provided it 
is from a reputed supplier. A 
sound card is not required. A 
floppy disk or IDE card is 
only necessary with a 486 
machine. The available mem- 
ory should be 16 Megabytes 


or more. 

Once everything looks fine 
so far, a cheap energy meter 
(£15-20 from builders mar- 
kets) and the following meas- 
ures will tell you how much 
energy is saved. 

To start with, relocate the 
CPU speed jumpers to select 
a setting of about 75 MHz. 
With some motherboards 
and CPUs, even lower 
speeds may be set up. 
Although apparently even 
more energy-wise, in practice 
you'll find that 25 to 30 MHz 
is the minimum you can get 
away with. In most cases 
however, you'll find that "the 
slower the more economi- 
cal". There are exceptions 
however. When testing a 
stripped-down 486DX 
machine no difference was 
noticed when the clock speed 
was reduced from 50 down 
to 25 MHz. You may also 
want to experiment a little 
with the CPU core voltage 
jumpers, making sure you 
never select a voltage higher 
than the original setting. If 
you happen to have a small 
stock of video, network and 
(if applicable) HD/floppy 
disk cards, it's very well 


worth the time and effort to 
swap these around for a 
bit as one card may con- 
sume far more power than 
the other. 

If you assemble the PC 
without the help of an ener- 
gy meter, be sure to use a 
PCI video card. 

After all this modding 
around, the PC will typical- 
ly consume 25 to 30 watts. 
Of course, there will be 
exceptions and tough cases 
but then these are easily 
recognised from boiling hot 
chips and ditto heatsinks. 

In principle, a floppy disk 
is sufficient for a small web- 
site, router or printer serv- 
er. You will need a hard 
disk however if want to run 
a large website with photos 
on it and FTP access. The 
hard disk may, of course, 
be replaced with an IDE 
Flash drive: very power- 
wise, quiet and perfectly 
working! 

The BIOS settings will usu- 
ally require some changes. 
The BIOS will be specific to 
the motherboard used, so 
some research will be 
needed to find and under- 
stand the settings that mat- 
ter. Enable the 'halt on 
errors' option in the 
Standard CMOS Setup 
menu. Then go to the 
Power Management menu 
and change the settings to 
those indicated in the 
screendump. Next, click on 
'Save & Exit'. At that point 
you are ready to proceed 
with the installation of an 
operating system, for exam- 
ple, Freedos or Freesco. 
Both have a "dot org 
web address. 


next one, please!" 

"Took a bit longer than the 
decimal ones!" 

"Nice puzzle; blood, sweat 
and beer!" 

"Could not put it down and 
got off the wrong subway sta- 
tion." 

"A most enjoyable distrac- 
tion, I will look forward to 
more of these puzzles in the 
future." 


Visual Basic Course 

Dear Elektor people — I was 
thrilled to see the free Visual 
Basic course booklet with the 
January 2006 issue. A fan- 
tastic initiative, thank you Mr 
Petros Kronis and Elektor for 
your efforts! 

When I wanted to download 
Visual Basic Express edition 
2005 I got a message saying 
the product required 


Windows 2000. 

Unfortunately, my PC has 
Windows 98. Does this 
mean I am unable to pro- 
ceed? I was unable to find a 
'minimum requirements' list in 
your booklet. 

Jose Qvik (Netherlands) 

The big advantage of the latest 
version of Visual Basic is that it's 
free. Most programs discussed in 


the booklet will also run using 
older versions of Visual Basic , but 
these , alas , are not free. Maybe 
you should start looking for an 
older VB version someone is will- 
ing to sell at a low price. 


PIC programming 
Dear Editor and lab staff — I 
am looking for a handbook 


3/2006 - elektor electronics 


9 



INFO & MARKET 


MAILBOX 


Corrections & Updates 

SC Analyser 2005 
April 2005, p. 34, 030451-1 

Several readers have reported difficulties with the configura- 
tion bits to set up in the PIC. The confusion is owing to poor- 
ly defined standards at Microchip. Because all status bits 
are at 7 1 7 with a new processor, there are options where '1 ' 
means 'enabled', while for other options it means 'dis- 
abled'. To add to the confusion, some programmer systems 
(including the one currently in use at Elektor labs) employ 
the notation 'on' and 'off'. 

The essential options are the oscillator, watchdog timer, low- 
voltage programming and in-circuit debugger. The following 
list provides the desired state for each option, where '0' = 
unprogrammed and '1' = programmed. 



Options: 

bit 13, CP: 

bit 1 1, DEBUG: 
bit 10-9, WRT1 : 

bit 8, CPD: 

bit 7, LVP: 

bit 6, BOREN: 
bit 3, PWRTEN: 
bit 2, WDTEN: 
bit 1-0, FOSC1 : 


Flash Program Memory Code Protection 
bit; 1 

In-Circuit Debugger Mode bit; 1 
WRTO Flash Program Memory Write 
Enable bits; 1 1 

Data EEPROM Memory Code Protection 
bit; 1 

Low-Voltage (Single-Supply) In-Circuit 
Serial Programming Enable bit; 1 
Brown-out Reset Enable bit; 1 
Power-up Timer Enable bit; 0 
Watchdog Timer Enable bit; 0 
FOSCO: Oscillator Selection bits; 1 1 


DDS RF Signal Generator 
October 2003, p. 1 4, 020299- 1 

Pin 6 of IC3 is erroneously connected to the +9 V supply 
rail. The relevant 1C input is however designed to handle 
logic levels with a maximum High level of +5 V. Although 
the 1C will not take damage from the +9 V level applied, it 
is recommended to cut the relevant connection and wire 
pin 6 to the +5 V supply rail. 


or a course covering PIC 
microcontroller programming. 
Several questions in forums 
failed to produce relevant 
answers, so I am now turning 
directly to you. Do you have 
any relevant books? 

Chris (UK) 

All books we have available are 
faithfully listed on our website , 
see SHOP — > Books & CD-ROMs. 
Unfortunately there's not yet a 
book that matches your exact 
requirements. However ; we found 
one on the Internet at 
www.mikroelektronika. co.yu/ 
english/ product/books/ 
PICbook/ picbook.htm 
and a series of tutorials at 
www. mstracey. btinternet. co. uk/ 
pictutorial/picmain.htm 


MSC1210 

programming tweak 

Dear Editor — I am happy 
to report further progress 
with my Elektor MS C 1210 
microcontroller system 
( Precision Measurement 
Central, July August 2003 
and Micro Webserver, 
July/August 2004, Ed.). I 
happened to discover that 
replacing the instruction 
printf("%f ....) somewhere in 
the program by printf("%u 
....) reduces the amount of 
code generated by about 
20%. Apparently, floating 



point output is very byte con- 
suming. The 20% extra 
space I gained in this way 
allowed me to extend the 
program to my personal 
requirements. 

Patrick (Belgium) 

Thanks for letting us know Patrick , 
I'm sure other MSC1210 users 
will find this useful information. 


Four steps 

to LEDs on the mains 

Dear Jan — I really liked the 
extra-large instalment of 
Design Tips in the January 
2006 issue. Unfortunately, in 
a number of cases the com- 
ponent references in the texts 
with Four Steps to LEDs on 
the Mains are not consistent 
with the schematics you have 
printed. I'm happy to say that 
despite the discrepancies I 
did not have problems under- 
standing the operation of the 
circuits. Many thanks for an 
interesting article. 

Walther (UK) 

Unfortunately the component num- 
bering in the drawings was 
changed from the author's hand 
drawn originals we used to pro- 
duce the texts. Also , LED D10 in the 
third drawing is shown the wrong 
way around. Given the simplicity 
of the circuits discussed we trust the 
errors do not detract too much 
from the educational value. 


MailBox Terms 

- Publication of reader’s correspon- 
dence is at the discretion 
of the Editor. 
- Viewpoints expressed by corres- 
pondents are not necessarily 
those of the Editor or Publisher. 

- Correspondence may be 
translated or edited for length, 

clarity and style. 

- When replying to Mailbox 

correspondence, 
please quote Issue number. 

- Please send your MailBox 

correspondence to: 
editor@elektor-electronics.co.uk or 

Elektor Electronics, The Editor, 
1000 Great West Road, 
Brentford TW8 9HH, England. 


10 


elektor electronics - 3/2006 









MikroEtaktronika 


MICROCONTROLLER DEVELOPMENT TOOLS 


HCniicru 


Easy ^ 3 

plCmicro Starter Pack 
£99.00 



4 Kjuylily di)vuk»pirtviTfl I.KMiU 

4 OuilMn USB 2. ft programmer 

* Winctawa9a^i , ?00(J.^P oompatfele 

- SUppoflg 8. 14. 18. 26 and 4flpm DIP 
niKiioci5fiirDii^i^rforntnenpf. 12#-. 
16 F and 18 F P ICmicro Families 

« Qn-befltf'd le d*. switch®, 7- segment 
displays- polemiomelm RS-23E 
mis riaoe USB and PS 2 come do is 

* AM I'D lines Available lor expansion 

4 Ea&yPlC3 Slide-1 Pack ihcHrd**: 

- PtCiaF452 microcontroller 

< 16x2 characlar LCD 

■■' 126*64 pixel graph*; LCD 
^ DG1S320 Eomporalurt terser 

J USB pf-ogramminqi power load 

*' Programming software and examples 



Easy sPIC2 
dsPIC Starter Pack 
£9900 



* Hgh qiMhty dwekHmwl bowd 
4 Built-in USB 2.0 progiammer 

* Windows Ha*MEt!200a:>EF' J comp/ilibla 

* Support 18. 28 and 40-pm Dip tkqdal 

cMiro«eni Irqm cfePlC30 fanny 
4- QrhtKwudLED*. switches. peiertti 
omfllfitf* Rs-232 inferlae#. PS^E and 
ICD;-? conoedoiE, a nd MMC-SD card 
Biol 

* All ID Unas available lor exp<r itf rin 

4 E;i&^^IC2SledwP^KirHAria*; 

- dsPICaof4(}lS digtlal sipiai cmUrofcr 
*' 16x2 character LCD 

* 128X64 pIXOl graphic LCD 

■" USB prpgraimining.^eiWflr lead 
Programming software and examples 


EJ 


VR 


Easy 3 

AVR Starter Pack 

£99,00 



» High quality dev a lop-mert board 

* Butft rn USBJ.Opfo^ranimai 

* Windows 0&-ME/2OOfrXP compaLt-le 
- Supports fl. 20 28 and 46-pin DF 

AVR mferoconl i nlle m 

* On-boatfd L E Ds, swil ufaes. potento- 
om flier. FtS-232 rnlarteofl AID 
and D^A and M L1C SD card slot 

« AM I D Unas available lor expansion 

* Ea*y*VR3 Sterter Pack include*; 

- 1 ATmo^ft853^miflrflflflntrfliier 

J 16x2 character LCD 
s 326x64 pixel graphic LCD 
^ DG1852Q tflmpor^lur& Hntor 

* USB pr*gfarriimin^ixiw«r iaad 

«■'' Programming software and examples 


Easy 

8051 Starter Pack 
£99,00 



■ High qpaUy develop™ id Hoard 

p Bdii in USB 2 0 pio^nnnmer 

* WmdowE gfijTME/SObO-'XP compaliile 

■ Support* PC 1 and 4Qpm DIP Atmel 

8Q81 Flash rraaflconlp^iflrs 

* On board IPOs, swJohaa. polerti- 
cjmetflr. RS 232 ■meflac*. 12 b* AJD 
and Di'A. and two addfitonaE Ei -till LCs 
porla 

* Al I I'D lines available ror scansion 

* E^ygosi planer Pscic includes; 

v 40-f in BO 51 rmcrooomroElar 

/ 16x2 character ICO 

/■ 1?&k& 4 ptfd graphic LCD 

* DS 1 3&20 IhrirpoioHiro sensor 

v USB programming power iaad 

* Pr^iarrtnin>q Soil waiu and samples 


BIG' 3 80-pin 
PlCmicro Starter Pack 
£119.00 



V ' ■■.■ t. ■ ■ - JL 
- >. ■ - •-«.- ' 


* High quality cfcrvefcpnwnt board 

■ BuiR-n USB 2,0 p logrummar 

■ Window* ®t'M£ i'2000/XP- compatfclfl 

* Supports Ihfl 1316*1 SQ-pln 

tifl4»W iFdrn |he 18f PlCnucro lamily 

* Cn board LEDs, *w4ch«s. poRonti- 
orhfllbl^, Iwn FIS 232 !rH 0 ifflCfl&, PS-2 
connedor, and MMC'SD and Corn- 
pad Flash caid dots 

■ Alt ID lines available tor expansion 

■ BKJPIC3 Slartar Pit*, UndudR: 

^ PtClsFB52D MCU module 

i 1 5x2 charade r LCD 
J 126X84 pixel graphic LCD 

* DSl852flterhpemlur6 mmtu 

■ USB programming.'power lead 

■' Pragrammng softwaie and examples 



IsPK PRO 64/80-pin 
dsPIC Starter Pack 
£14900 



* High Quality devflidprne m tenid 

* BuiH in USB 2.0 progiarnniei 

* Windf'jws- 93 HI ?itO" XI 1 compair.’lo 

■ Suppofl* 64 JWKl W-piri chgMal SKjnif 11 
tfinlmlEflr& trnm the d*PlC?b limtly 

- Orhbowd LCD*. * wile he*, iwe Fts 
232 inlarlaew. fiS-485 menace 1WO 
CAN interfaces, real- time dock 12-bfl 
AD and DA and C F card skn 

■ All 1*0 bnas available lor axpanston 
4 rfcPICPF&O srortflf PmM mciludw: 

dsFIC30F6D14 DSC module 
*' 16x2 character LCD 
r 128x64 pixel graphic LCD 

- DS18S20 Iflmfflrsturfl Sfln&5r 
k' USB pforjramniiingfjciwfir lead 

■■■ Programming software and examples- 



BIG M i 64-pin 
AVR Starter Pack 
£119.00 



« High q*. :-.lil y davalopmarrl boaid 

■ Suit- m USB J.&piogrsmmflr 

■ Wndows Sfl-'ME *2806 XP compalbla 
« ^uppoils 64 -pin AVR m ic rocord rotters 

■ Qn-b04td LED*. tWflCNSt, pfltfllllp- 
flPMrtett, l wo FiS-232 iintflrlncflt. ps-? 
Cfjfinflddr am MHCi^D and Coni- 
pad Flash card slots 

-■ All LD Rnas available loi expansion 
- Si^AVFt Siader Padc indutfw: 

* ATffl*gal2&MCU mflduto 
16x2 diarader LCD 
128x64 pixel graphic LCD 
osi8S20tflmi>tiF3tute sof 
*■' U$8 pfbgfamruwi^powflf l&sd 
« Programming! software and examples 


PSoC Starter Pack 
£119.00 



» High quaMy baufllqpmerK board 

* Birfl ‘Hi USB 2,8 prcpniim«f 

■■ WmxIowe W campalibUe 

* Supports B, 20, ?i and 4fl-pm DIP 
PSoC mixfld sAjnfli'Mntrollfli* 

* Dn-board LEDfi SMrtche*. polenli- 
emetofs. RS-232 IfMitooa, R^-485 
mlarTace. CAM pttariace. real-time 
dock, and MMCiBD and CF card slots 

r An ID lines available lor expansion 
■ Ea*yP$oC3$lartflrPflcif includes 
v 45 pm PSoC mrcroooniroler 

* 1 6x2 character LCD 

^ 126x84 pfXat graphic LCD 
v DS 1 8 S 26 lempflrfliiKfl 
4 USB programming-power lead 
^ Piogr3mnnng *Oltwaae ^hd examples 



^readboarcung System* ean supply al MikroE tettrarnkfi prcwhicfcs frem, ntocR cradfl and *bfl tards accepi&d Pnee* shewn extf nde daiivflry and VAI 


Bread boarding Systems 

Software and hardware development tools 


Tel: 0845 226 9451 

Web i www.b read boardi ng .co.uk 






INFO & MARKET 


NEWS & NEW PRODUCTS 


British computing power helps bring Were-Rabbit to life 



Sight Systems has helped bring 
the latest Aardman Animations 
film, "Wallace & Gromit: The 
Curse of the Were-Rabbit", to the 
screen with their high-tech cus- 
tom computer systems. Sight Sys- 
tems helped build a custom- 
developed computer called the 
Aardcase that helped Nick Park 
and his team to speed up the 
process of bringing the plasticine 
hero's, Wallace and Gromit, to 
life as well as creating the huge, 
mysterious veg-ravaging beast: 
the Were-Rabbit! 

The Aardcase is connected to 
the film cameras, capturing the 
images from up to 30 cameras 
directly to hard disc. It allows the 
animators to check the minute 
changes made from one frame 
the next in real time. Although 
many people assume that the 
technology behind blockbuster 
movies is associated with large 
Hollywood companies, Sight 
Systems has provided some tech- 
nology for several productions, 
including the last Aardman film, 
"Chicken Run". 

The Aardcase is a single board 
based PC with a passive back- 


plane in a ruggedised 61) 19" 
rack mount case. Aardman 
demanded a highly robust prod- 
uct that could be easily trans- 
ported - including being 
wheeled over the cobbled paths 
near their office - so Sight Sys- 
tems designed a custom vibra- 
tion-resistant solution to ensure 
that the computer would stand 
up to this rough treatment. The 
system includes a video capture 
PCI card, an optical drive for 
storing captured film, and two 


hard drives. The two drives sep- 
arate the video, which is stored 
on a high-performance SCSI 
drive, from the operating system 
and software that is held on a 
cost-effective ATA drive. 

The custom case routes the video 
connections and other I/O to a 
rear panel designed for use by 
animators with little or no knowl- 
edge of PCs. In addition to the 
video inputs, the system also pro- 
vides a 1 2V supply to power the 
cameras. Installed software 


includes the Perception Video 
Recorder from DPS as well as a 
custom Video Assist and Digital 
Video Frame store developed by 
Aardman that helps the anima- 
tors plan character movements 
on screen, and allows them to 
check the frame currently being 
shot with those already com- 
pleted to ensure continuity. 

"We have provided many sys- 
tems for the film and broadcast 
industry, which is only one of the 
applications that use our prod- 
ucts," said Phil Walters, MD of 
Sight Systems. "Our long rela- 
tionship with Aardman shows 
that we can meet the needs of 
the most demanding customers 
over an extended period of 
time. 

Wallace & Gromit: The Curse of 
the Were-Rabbit is showing now 
at local cinemas, featuring the 
voices of Helena Bonham-Carter 
and Ralph Fiennes as well as 
Peter Sallis, who has been the 
voice of Wallace since the first 
short. 

More information is available at 
www.sightsystems.co.uk. 

( 065079 - 4 ) 


In-vehicle video recorder 



Reliance Motor Services (RMS) 
has announced their success 
with deView's Mobile Digital 
Video Recorder System (DV-M8), 
manufactured by Security Man- 
ufacturing Limited (SML). 

Reliance Motor Services are 
renowned for their success and 
are the 2005 winners of the 
"Bus Operator of the Year" 
award at the RouteONE Excel- 
lence Awards." due to their qual- 
ity and commitment to their cus- 
tomers and staff. RMS operates 
throughout the Vale of York. RMS 
contacted Sewell of Leeds nearly 
6 months ago to find out what 
would best suit their require- 
ments for CCTV for double deck 
buses, which were being added 
to their fleet. Sewell of Leeds 
arranged to demonstrate the 
deView DV-M8 and gave them 
the option of a range of deView 


cameras and driver screens to 
meet their needs. 

The DV-M8 can be installed into 
any vehicle type and you can 
choose what you require to view 
internally or externally on the 
vehicle. Camera installation is 
quick with well-designed camera 


mounting making set up quick 
and simple. The DV-M8 system is 
easy to add or integrate options 
such as reversing camera sys- 
tems, as well as being compact 
and having the ability to bolt 
directly to the vehicle without 
compromising reliability makes 


installation a breeze. 

Full details of all deView prod- 
ucts can be found on their web- 
site at www.deview.com and for 
more information regarding the 
DV-M8, please contact Gerry 
Burns, Special Project Sales. 

( 065079 - 6 ) 


12 


elektor electronics - 3/2006 




FPGA-based mobile applications board 


QuickLogic Europe has released 
a low-power FPGA development 
tool for Intel's PXA27x based 
Processor Developer's Kit - the 
'Mainstone' DVK - enabling 
rapid adoption of emerging tech- 
nologies that are not natively sup- 
ported. The new Mobile Appli- 
cation Board (MAB) can provide 
seamless connectivity between 
XScale processors and periph- 
eral interfaces such as Mini PCI, 
CardBus, SDIO and IDE. 

QuickLogic's FPGA-based MAB 
enables the development and 
performance verification of 
design ideas for a variety of 
peripheral interfaces such as Wi- 
Fi, HDD (Hard Disk Drive), 
10/1 00/1 G Ethernet, MPEG 
devices, SD memory, and many 
more. It connects directly into 
the VLIO connector of the DVK, 
which allows designers to make 
system measurements and archi- 
tecture trade-offs including 
power consumption, perform- 
ance and cost. 

MAB allows electronic design 
teams start software develop- 
ment prior to receiving final 
hardware. This ability to design 
hardware and software in paral- 
lel can provide product develop- 
ers with a critical competitive 
advantage, by significantly 
reducing time spent in develop- 
ment of popular portable prod- 
ucts such as GPS, smart phones, 
portable media players, and 
portable industrial systems. 

The QuickLogic Mobile Applica- 



M1TACHI 

mad pftvi 


■mm 


W TT* 

Travetatar 


QutfXLQChC 


QuicxLogic 

XScale Mobile A.B 


ft? V 10 ilJIOL Ik CANADA 

<£> rPH 

MirtJ PCI 


( r r i 

r 

fit i ? 

i it t i Hit 1 i 





tion Board is available immedi- 
ately. Complete solution packs 
are available for both Wi-Fi and 
HDD connectivity. They include 
the Mobile Application Board, 
an Eclipse II QL8325 device in 
a 484-ball BGA package, refer- 
ence design files and software 


drivers for Windows CE, Win- 
dows Mobile, and Linux. 

In addition to this solution for 
QuickLogic's Eclipse II family of 
FPGAs, the company will release 
a MAB based on PolarPro, the 
new ultra low power FPGA, at 
the end of Q1 , 2006. 


For more information, access: 
www.quicklogic.com/mab 
QuickLogic Europe, 

1 5 London Street, 

Chertsey KT16 8AP,UK. 

Tel. +44 1932 579011. 
www.quicklogic.com 

(065079-5) 


Advertisement 


Your price conscious PCB supplier 


Verified 



CIRCUITS 


Online price calculation 
Online ordering 
Online order tracking 
Online 24/24H and 7/7D 


a la carte 


pooling for standard boards 
up to 6 layers 
from 1 to 1000 pieces 
from 4 working days onwards 


- technology at the right price 

- up to 8 layers 

- from 1 to 1000 pieces 

- from 3 working days onwards 


Interested? Contact us: +32 15 28 16 30 
E-mail: euro@eurocircuits.com 


On demand 


your board, our challenge 
up to 20 layers 
from 1 piece onwards 
from 2 working days onwards 


3/2006 - elektor electronics 


13 






INFO & MARKET 


NEWS & NEW PRODUCTS 


Three-phase PWM controller 


International Rectifier announced 
a three-phase PWM control 1C 
with integrated drivers for DC- 
DC converters. The IR3094MPbF 
enables up to 40% circuit size 
reduction when used with Inter- 
national Rectifier DirectFET™ 
MOSFETs. The smaller footprint 
makes the IR3094 ideal for 
space-constrained applications 
like DDR memory in rack servers 
and point-of-load (POL) modules 
used in high-density data sys- 
tems. 

A typical 80A, three-phase syn- 
chronous buck solution would 
require as many as 13 devices 
including one control and three 
drivers in addition to three MOS- 
FETs per phase. A chip set made 
with the IR3094 plus IRF6637 
and IRF6678 DirectFET MOS- 
FETs reduces the silicon compo- 
nent count to seven devices for 
the same output current. Three 
pairs of these DirectFET MOS- 
FETs can be placed directly next 


to the IR3094, creating a solu- 
tion that minimizes printed circuit 
board trace parasitics and 
enables optimum switching per- 
formance. 

The IR3094 is designed for 
applications requiring a 0.85 V 
to 5.1 V output. The new 1C is 
housed in a compact 7mm x 
7mm MLPQ package, and fea- 
tures 3A gate drive capability, a 
1% accurate reference voltage, 
adaptive voltage positioning and 
programmable switching fre- 
quency up to 540kHz. The 
IR3094 provides system protec- 
tion with programmable soft 
start, hiccup over-current protec- 
tion, over-voltage protection, and 
a "power good" indicator. 

The IRF6678, an ideal synchro- 
nous MOSFET, features a very 
low typical device on-resistance 
of 1.7mOhm at 10VGS and 
2.3mOhm at 4.5VGS. The 
IRF6637 is best suited as a con- 
trol MOSFET, with very low 



Miller charge of only 4nC and 
typical device on-resistance of 
5.7 mOhm at 1 OVGS and 
8.2mOhm at 4.5VGS. Both 
MOSFETs are housed in the 
medium can DirectFET package, 
occupying the same board area 


as a SO-8 with only a 0.7mm 
profile, and improved thermal 
performance through double- 
sided cooling. 


www.irf.com 


( 065079 - 3 ) 


LPKF ProtoMat S42 PCB Plotter 


LPKF Laser & Electronics AG 
presents the LPKF ProtoMat® 
S42 circuit board plotter, a new 
entry-level circuit board plotter 
for in-house rapid PCB prototyp- 
ing. This compact system pro- 
vides precision and performance 
for quickly and easily milling 
and drilling single-sided and 
double-sided circuit board proto- 
types in a single day. 

The LPKF ProtoMat® S42 is an 
excellent tool for colleges and 
technical institutions, allowing 
students and instructors to pro- 
duce printed circuit boards that 
are production quality and 
chemical free, immediately in the 
classroom environment. Low con- 
sumable costs, instant turn- 
around, and no need for exter- 
nal vendors encourages more 
practical exercises and experi- 
ments in the classroom or labo- 
ratory. 

The ProtoMat® S42's 42,000 
RPM spindle motor makes it an 
excellent entry-level performer 



for producing quality PCBs in- 
house. Easy handling can be 
increased with the addi- 
tion of an optional 
recognition camera, as 
well as a vacuum table. 


LPKF Laser & Electronics 
AG, Osteriede 7, 
D-30827 Garbsen, 
Germany. 

Tel.: +49 (0)5131- 
7095-324, 

Fax: +49 (0)5131- 

7095-90. 

www.lpkf.de 

( 065079 - 1 ) 


14 


elektor electronics - 3/2006 






PC Oscilloscopes <& Analyzers 


Analog + Digital 

100MHz Digital Oscilloscope 
Dual Channel Digital Scope using 
industry standard BNC probes or analog 
inputs on the POD. 


40MS/s Logic Analyzer 

8 logic, External Trigger and special 
purpose inputs to capture digital 
signals down to 25nS. 

Mixed Signal Oscilloscope 

True MSO to capture analog waveforms 
time-aligned with logic using sophisticated 
cross-triggering on any input. 

Real-Time Spectrum Analyzer 

See spectra and waveforms in 
real-time displayed simultaneously 

Waveform Generator 

Load up to 128K arbitrary waveform and 
replay via BNC B. Capture circuit response 
simultaneously on BNC A 


Get the full picture with BitScope 
Mixed Signal Oscilloscopes 



Turn your PC into a powerful Digital Storage Oscilloscope! 

See inside your circuit with simultaneous analog, logic and spectrum 
displays to make tracking down those elusive real-time bugs much easier. 

BitScope combines a high speed synchronized storage scope and logic 
analyzer with a programmable waveform generator and spectrum analyzer. 

With "Smart POD" connected active probes and multiple software options 
you've got the perfect low cost high performance test and debug solution! 


U; ( 

- w 


r . V 

0* w v 







o 



Standard 1 M/20pF BNC Inputs 

200uV-20V/div with xl 0 probe 
S/W select AC/DC coupling 
Switchable 50ohm termination 
Arbitrary Waveform Generator 


BitScope Smart POD probe connector 
8 logic channels, cross-triggering 
Dual channel analog inputs 
Async serial I/O for external control 
Supports active probes 


USB 2.0 or Ethernet Connectivity 
Single cable to PC or switch 
Compressed data transmission 
Ethernet option uses UDP/IP 
Internet addressable device 


Expandable and Programmable 

Simple ASCII Protocol 
BitScope Scripting Language 
Add active probes and devices 
Supplies up to 500mA via POD 


BitScope and your PC provide an array of Virtual Instruments 




■r • dp 

\ J 


BitScope DSO software for Windows and Linux 


BitScope's integrated design uses standard oscilloscope probes and 
a growing range of custom probes to provide functionality equal to 
instruments many times the price. 

BitScope plugs into third party software tools and has an open API 
for user programming and custom data acquisition. 


www. bitscope . com 


3/2006 - elektor electronics 


15 





HANDS-ON 


FPGA MODULE 



Modern technology 
for everyone 


Paul Goossens 


FPGAs have established a 
firm position in the modern 
electronics designer's 
toolkit. Until recently, these 
'super components' were 
practically reserved for 
specialists in high-tech 
companies. That's all 
changed now thanks to 
low component prices 
and free design software, 
so it's high time to devote 
attention to this technology 
in Elektor Electronics. The 
FPGA module discussed in 
this article forms the core 
of various upcoming 
projects in the magazine. 



16 


elektor electronics - 3/2006 














If you want to use an FPGA in your 
design, there are several things you 
can’t do without, including a program- 
ming interface and configuration mem- 
ory. We thought it would be a good 
idea to incorporate the standard items 
normally associated with an FPGA into 
a single electronics module, in order to 
avoid the need for everyone to reinvent 
the wheel each time. This module can 
then be used as a ‘digital core’ for var- 
ious circuits. A major benefit of this 
approach is that it allows 
designers to concentrate 
on specific applica- 
tions without 
having to 
worry about 
the sound- 
ness of the 
FPGA element. 

Getting started is 
the hard part 

For those of you who 
haven’t used FPGAs before, 
this module and the associ- 
ated prototyping board 
described elsewhere in this issue 
form an ideal starting point for 
learning about FPGAs. 

It’s impossible to avoid using SMDs in 
a circuit such as this. To make things 
even worse, we decided to use an 
FPGA in a BGA package for this cir- 
cuit, which means DIY soldering with 
a normal soldering iron is simply 
impossible. Soldering the other mem- 
ber of the family (in a PQFP package) 
is also very difficult. However, using 
these ‘difficult’ components allows the 
overall dimensions of the circuit board 
to be kept reasonably compact. 


Fortunately, you don’t have to worry 
about assembling the board, because 
the FPGA module is available from 
Elektor Electronics with most of the 
components pre-assembled. The only 
components you have to solder by 
hand are the connectors. 

Besides this module, you will need a 
programming interface that sits 
between the PC and the FPGA board. 
Naturally, we’ve also developed a 
design for this interface. 


Technical features 

• Altera Cyclone FPGA 

• 1 2,060 logic elements 

• 4 MB configuration memory 

• 8 MB user SRAM 

• 1 MB user flash RAM 

• on-board 50-MHz clock 

• JTAG/programming interface 

• Byteblaster compatible 

• 80 user I/O lines 

• dedicated clock signals 

• indicator LED 

• built-in switch-mode power supply 

• small multilayer PCB (1 10 x 77 mm) 

• supplied ready to use 


It takes more than just an FPGA 
to make a circuit 

As already mentioned, you’ll need 
some peripheral electronics to enable 
you to use an FPGA in a practical cir- 
cuit. One of the most important ele- 
ments beside the FPGA is the configu- 
ration memory. In contrast to most 
FPGAs, the configuration memory 
retains its data when the supply volt- 
age is switched off. 

Each time the unit is switched on, the 
FPGA must be configured again before 
it can fulfil its intended function. Fortu- 
nately, FPGA manufacturers have 
developed special memory ICs that 
can configure FPGA ICs automatically 
when power is switched on. Our cir- 
cuit includes one of these memory ICs. 
Easy programming of the FPGA and 
the configuration memory during the 
development phase is also highly 
desirable. That’s why a programming 
interface (using JTAG) also forms part 
of the standard peripheral circuitry. 
Another quite important part of such a 
circuit is the power supply. The inter- 
nal operating voltage of most such ICs 
is quite low (1.5 V in our case). The 
power supply must be able to handle 
short current spikes without problems. 
In addition, a different voltage is used 
for the inputs and outputs. Here we 
decided to use 3.3 V. The supply for 
this voltage must also be able to 
deliver fairly heavy currents and 
remain stable under heavy loads. 

Our circuit also includes an oscillator, 
SRAM and flash memory. They can be 
used freely by the application. 


All the individual elements of the cir- 
cuit can be easily identified in the 
schematic drawing. 

The design 

Due to the size of the schematic draw- 
ing of the FPGA module, we decided to 
print it on a foldout which may be 
found in the centre of the magazine. 
Let’s start at the beginning with the 
power supply. It is built around a 
TPS75003 (IC2) and can work with an 
input voltage in the range of 4. 5-6. 5 V. 
This IC is specially designed for use in 
FPGA circuits. It contains two switch- 
mode power supply circuits and one 
series regulator. The latter is not used 
in our circuit; only the two switch- 
mode circuits are used. 

A step-down regulator that provides a 
3.3-V supply voltage is implemented 
using Tl, Dl, LI, Cl and associated 
components. IC2 periodically drives 
FET Tl into conduction to allow a cur- 
rent to flow from the input voltage via 
Tl, LI and Cl. This causes the current 
through the inductor to increase, 
which in turn causes capacitor Cl to 
be charged. When IC2 switches off the 
FET, the current flowing in LI cannot 
stop immediately, so it continues to 
flow through Cl and Dl. Rl, R3 and C3 
provide feedback so IC2 can determine 
whether it has to supply more power 
or less power. 

The values of these components have 
been chosen such that IC2 tries to 
maintain the output voltage at 3.3 V. 
Resistor R2 is a sense resistor. IC2 will 
limit the current if the voltage across 


3/2006 - elektor electronics 


17 


HANDS-ON 


FPGA MODULE 



Figure 1. The programming mode of the Quartus program. 


this resistor rises above 0.1 V. The 
value used here (50 mil) results in a 
current limit threshold of 2 A. 

A similar circuit is built around T2, 
with only the values of the feedback 
resistors being different. They are cho- 
sen to yield an output voltage of 1.5 V. 
The electrolytic capacitors at the input 
buffer the input voltage. They also pre- 
vent fast current spikes from leaving 
the board. That prevents generation of 
interference that could impair the oper- 
ation of nearby equipment. 

The FPGA is powered from these sup- 
ply voltages, but not directly. The sup- 
ply lines for the two sections of the 
FPGA are first fed through ferrite 
beads to block high-frequency radia- 
tion. The supply voltages are also 
buffered close to the IC by several 
additional capacitors. That may appear 
to be a bit of overkill, but fairly large 
switching currents at high frequencies 
can flow through the FPGA, depending 
on the final circuit configuration. It is 
always a good idea to keep the paths 
of such currents as short as possible. 
Otherwise the circuit can easily gener- 
ate too much undesirable interference. 


And now for the digital part 

Now that we’ve looked after the sup- 
ply voltages, we can turn to the digital 
portion of the circuit. The first thing the 
FPGA needs is a configuration mem- 
ory. That memory is present in the cir- 
cuit in the form of IC6, which has been 
designed to work with the FPGA. 
When the MSEL signals from the 
FPGA are at ground level, the IC 
expects to find a configuration memory 
(such as the EPCDS4) connected to it. 
The FPGA will then independently 
control the memory IC and read data 
from it in order to configure itself based 
on the data. That makes the process 
very easy in actual use. 

A programming connector (K5) is pro- 
vided for programming IC6. The pin 
assignments of this connector have 
been chosen to make it compatible 
with the Altera ‘Byteblaster’ program- 
ming interface. 

Connector K6 is used for in-circuit pro- 
gramming of the FPGA from a PC. That 
makes it unnecessary to first program a 
design into the configuration memory. 
This connector can be used to quickly 
test a design without using the config- 


uration memory. 
Here again, the sig- 
nals are arranged 
to be compatible 
with the Byte- 
blaster interface. 
The circuitry 
around T3-T5 
forms an indicator 
circuit that clearly 
displays the status 
of the FPGA using 
bicolour LED D3. 
Any error states 
that may occur are 
also indicate visibly 
by D3. 

An abundance 
of I/O 

As this circuit is 
intended to be 
used for all sorts of 
applications, it has 
an abundance of 
I/O pins. They are 
accessible via con- 
nectors K3, K4, K7, 
K8 and K2. These 
connectors fit stan- 
dard pin headers 
with 0.1” pin spac- 
ing. That avoids 
the difficulties of using SMD connec- 
tors on the motherboard and thus 
makes it quite easy to connect the 
board to your own hardware. 
Connectors K3, K4, K7 and K8 present 
an impressive total of 80 I/O pins of the 
FPGA to the outside world. The I/O 
lines are all routed to one side of each 
connector. The supply voltage (3.3 V) 
and ground are available on the other 
side on alternating pins. You can use 
the supply and ground pins to power 
your own circuit if it doesn’t require too 
much current. This supply voltage is 
also filtered on the module by a ferrite 
bead and two capacitors. 

Connector K2 provides a special con- 
nection. Besides ground lines, it has 
several signals that are specifically 
intended to be used as clock signals. 
Pin 10 is an input that can be used to 
supply an external clock signal to the 
FPGA. The remaining even-numbered 
pins are all connected to the outputs of 
the internal PLLs of the FPGA. 

Of course, it’s possible to provide an 
external clock signal on any other 
desired input of the FPGA, but these 
pins are specifically intended to be 
used for that purpose. 


18 


elektor electronics - 3/2006 





The extras 

Many FPGA-based designs require 
memory. Although there is memory 
available in the FPGA, it’s not enough 
for many types of applications. In light 
of the fact that a ‘softcore’ processor is 
often used, a flash memory can be 
quite handy for storing the firmware of 
the processor. That makes it possible 
to use larger amounts of code in appli- 
cation designs without taking up addi- 
tional space in the FPGA. The flash 
memory takes the form of IC5 in the 
schematic diagram. 

A bit of extra RAM can also be desir- 
able in some cases. Besides being use- 
ful if one or more softcore processors 
are used in the FPGA, additional RAM 
can also be welcome for various types 
of signal processing. 

The RAM memory is provided by IC3 
and IC4. These ICs have a capacity of 
4 Mbits and are configured as 256K 16- 
bit words. Signals BHE and BLE can be 
used as two separate CE lines, with 
BHE being the chip-enable line for the 
upper byte (D8-D15) of the data lines 
and BLE the chip-enable line for the 
lower byte (D0-D7). That means this 
memory can also be used as a 512-KB 
memory with 8-bit data. 

IC3 is connected directly to the FPGA, 
while IC4 shares its data and address 
busses with the flash memory (IC5). 
The busses are shared to ensure that 
enough I/O pins of the FPGA are kept 
free for the user connectors. However, 
that means the FPGA cannot read or 
write the RAM and flash memory at 
the same time. That doesn’t form a 
major problem in practice, especially 
when softcore processors are used. 
That completes the description of the 
main parts of the circuit. 

We already mentioned that the circuit 
board for the module is provided nearly 
fully assembled. The only thing you 
have to do is to solder the eight pro- 
vided connectors to the board. Connec- 
tors K2, I<3, K4, K7 and K8 are fitted on 
the bottom of the board. The other 
three connectors are fitted on the top 
of the board (on the component side). 
Make sure pin 1 of each connecter is in 
the right position, which is marked by 
a ‘1’ on the component overlay. 


Programming interface 

This module by itself is only a starting 
point. The FPGA and/or configuration 
memory must be programmed before 
they can be used. That requires a pro- 


gramming interface. The schematic 
diagram of the programming interface 
is also shown on the foldout. It con- 
nects the FPGA or configuration mem- 
ory to the parallel port of a PC. The 
programming interface is compatible 
with the Altera Byteblaster interface 
and can be used with free Altera soft- 
ware. The circuit is quite straightfor- 
ward. 

Everything is powered by 3.3 V taken 
from the FPGA module. The two ICs 
are used to convert the +3.3-V signals 
from the FPGA to + 5-V signals for the 
PC and vice versa. The 100-Q resistors 
prevent the + 5-V signals from raising 
the supply voltage above the allow- 
able level. 

The interface is connected to the par- 
allel port of a PC via connector K3. K2 is 
a box header that is connected to the 
FPGA board by a 10-way flat cable 
with a matching plug at each end. 

If you just want to program the FPGA 
in order to test something, this cable 
must be connected to K6 ( JTAG) on the 
FPGA module. If you want to program 
the module so it can operate on its 
own, this cable must be connected to 
K5 (PROGRAM) on the FPGA module. 

Software 

A project of this sort naturally includes 
corresponding software. The manufac- 
turer of the FPGA we use here, Altera, 
has a very nice package of support 
software for its FPGAs. The free ver- 
sion of the software is called ‘Quartus 
Web Edition’ and can be downloaded 
from the manufacturer’s website 
(www.altera.com). It’s a quite sizeable 
download (240 MB at the time of writ- 
ing this article), but you can also 
request a free CD-ROM on the Altera 
website. 

After installing the software, which by 
the way goes without a hitch, you will 
need a licence. You can also obtain this 
via the Altera website, and it is valid 
for six months. At the end of the six 
months you can request a new licence. 
For the sceptics among our readers, 
the manufacturer has assured us that 
this software will remain free in the 
future. 

There’s not enough room here to show 
you everything you can do with this 
software, and it’s equally impossible to 
present a full course in VHDL here. If 
you’re new to using FPGAs, you 
should have a look at the accompany- 
ing FPGA Prototyping Board described 
elsewhere in this issue. 


Testing 

Although this circuit does not have 
any real input or output capabilities, 
it’s still possible to make a simple 
test. 

After installing the software, it’s 
best to switch off your PC for the 
next steps. Start by connecting the 
programming interface to the paral- 
lel port of your PC. Next, use the 
supplied 10-way flat cable to con- 
nect the interface to the FPGA mod- 
ule. You should connect the flat 
cable to connector K6 (JTAG) on the 
FPGA module. Now switch on the 
PC and connect a power source to 
the FPGA (caution: maximum volt- 
age 6.5 V). 

Start up Quartus and then click on 
the programming icon in the menu 
bar, or click on the Tools menu and 
select Programmer (the result will 
be the same in either case). The pro- 
gramming window will be opened. 
Click on the Hardware Setup button, 
and then click on Add Hardware in 
the new window. Select ‘Byte- 
blaster’ and specify the printer port 
you connected to the programming 
interface (usually LPT1:). 

If you then click on the Autodetect 
button in the main window, the pro- 
gram will automatically detect your 
FPGA (EP1C12). That way you can 
be sure the FPGA is working and 
the supply voltage is present. 

( 040477 - 1 ) 


The Versatile FPGA module can be 
ordered from 

Elektor Electronics Readers Services 
under order number 040477-91 . 


Included 

items 

• FPGA module (ready to use) 

• programming interface (ready to 
use) 

• programming cable 

• interconnect cable (between PC 
and programming interface) 

• 8 pinheaders (supplied 
separately) 


3/2006 - elektor electronics 


19 



HANDS-ON 


FPGA PROTOTYPING BOARD 



VGA 

A genuine VGA output that you can 
use to display text and imagery on a 
PC monitor. It's all done with only a 
few standard components. 

See page 24. 


Ethernet 

Your link to the Internet. The associat- 
ed 1C provides the coupling between 
the analogue and digital portions. 

See page 24. 


USB 

This USB interface makes communi- 
cation with your PC fast and easy. 
And it takes only five components, 
including the connector! 

See page 24. 


Analogue I/O 

Four analogue inputs and one ana- 
logue output. In addition to all the 
digital artillery on the board, an ana- 
logue interface is naturally indispen- 
sable. This I/O port has a resolution 
of 8 bits, which is enough for most 
applications. 

See page 24. 



mu mi 


uuo>xow 


* ■ ™ 







f ■ 

111 

J - r . ■ 



1 


!£l ■ ■ ■ 

IhCLv ‘ 1 m! 



i lip 










Mi 



i> 

1 

jJ 



P mm in: 

iiW 

ill 


\\\ 


i VI 

lTI f 




Digital I/O 

LEDs 

This interface allows you to connect 

You can use the LEDs for a visible 

your own circuitry to the 

indication of the status of 

prototyping board. 

various components. 

See page 24. 

See page 24. 


20 


elektor electronics - 3/2006 















Q Q 00000^0 


Power supply 

The power supply is pretty tolerant. 
As long as the input voltage is some- 
where between 6 V and 20 V, the 
regulator will take care of the rest. 
You don't even have to worry about 
getting the polarity right - the power 
supply circuit doesn't care. 

See page 25. 


PS/2 

A port for a PC keyboard and 
mouse. 

See page 25. 


LCD 

A two-line LCD module with a maxi- 
mum of 16 characters per line. An 
essential part of every proper proto- 
typing board! 

See page 24. 


Audio I/O 

With 16-bit stereo input and output, 
this prototyping board can also hold 
its own in the audio world. 

See page 25. 


Displays 

The ideal way to display numbers. 
Also handy for displaying the date 
or time. 

See page 24. 


Pushbuttons 

Besides all sorts of sophisticated 
inputs and outputs, simple operation 
using pushbuttons is often desirable. 

See page 24. 


DIP switches 

For enabling or disabling options. 
Naturally, they can also be used as 
independent switches. 

See page 25. 


3/2006 - elektor electronics 


21 

















HANDS-ON 


FPGA PROTOTYPING BOARD 


This prototyping board 
provides an environment for 
the FPGA module that 
enables it to do something 
useful. That gives you an 
opportunity to discover the 
capabilities of our FPGA 
module for yourself. 
Naturally, you don't have to 
make this voyage of 
discovery all on your own - 
a course in the form of a 
series of instalments in 
upcoming issues will guide 
you on your way. 


We’ve designed a prototyping board 
that enables the FPGA to be used for a 
variety of tasks. As you can see from 
the list of features at the head of the 
article, it’s equipped with quite a few 
modern interfaces. 

For many of our readers, designing a 
circuit that will ultimately be imple- 
mented in an FPGA will be a totally 
new experience. For that reason, we’ll 
start a series of articles on FPGA pro- 
gramming in next month’s issue. It will 
be based on the prototyping board 
described here. 

Just like the FPGA module, this circuit 
board is supplied in ready-to-use form. 

»> 


Figure 1 . Schematic diagram of the FPGA 
prototyping board. The board layout is available 
free of charge in PDF format at www.elektor- 
electronics.co.uk. 


K3 


+5V 

© 


O 

o 

§ 


© 

© 

© 

© 

© 

© 

© 

© 

© 

© 


10 


+5V 

© 


R4 


a I 

o I 


15 


14 


C18 


lOOn 


C17 

nr 


100n 


16 


© 


AOUT 

A0 

IC3 

A1 

AIN0 

A2 

AIN1 

OSC 

AIN2 

SDA 

AIN3 

SCL 

PCF8591 

VREF 

EXT 

AGND 

-1- 


13 


11 

9 


K8 


1 

3, 5 

7 | 9 

1 1 1 13 

1 5 1 17 

19, 21 

23, 25 

27, 29 

31, 33 

35, 37 

39, 

d 

c 

\ o d 
? 9 <; 

\> o d 

? 9 <; 

o c 

? 9 c 

\ o d 

\> o d 
2_2J 

\> 0 d 

?9J 

) o d 

\> o d 

? 9 

o d 

? 9 c 

\ d) 

? 9 

2 

4 6 

8 10 

12 14 

16 18 1 20 1 22' 24' 26 1 28 1 30 

32 34 

36 38 

40 


X 


oc 

X 


xxxx 


X 


+ 

a 

m 

c r > 


□ 

g 

xxxX 


x 


+3V3 


10 


12 


*x 


K5 


+5V 

© 


O 

5 


© 

© 

© 

© 

© 

© 

© 

© 

© 

© 


+5V 

©- 


2 

4 

3 

5 

4 

6 

5 

7 

6 

9 

7 

10 

8 

11 

9 

12 


10 


C19 

ir 


16 


lOOn 


PO 

PI 

P2 

P3 

P4 

P5 

P6 

P7 


© 


IC4 


SCL 

SDA 

INT 


PCF8574 


AO 

A1 

A2 


+5V 

© 


+5V 

©■ 


14 


15 


13 


C29 


| R18 


LCD1 


< 

04 

CO 


vss 

VDD 

VO 

RS 

R/W 

E 

DBO 

DB1 

DB2 

DB3 

DB4 

DB5 

DB6 

DB7 

LED+ 

LED- 


031 


lOOn - 


11 


12 


16 


Hh 

lOOn 


PO 

PI 

P2 

P3 

P4 

P5 

P6 

P7 


© 


IC6 


SCL 

SDA 

Tnt 


PCF8574 


AO 

A1 

A2 


+5V 

©- 


14 


15 


13 


C33 


7 

4 

8 

5 

9 

6 

10 

7 

11 

9 

12 

10 

13 

11 

14 

12 


15 


16 


R31 

ion 


+5V 

+) 


16 


Hh 

100n 


1 


PO 

PI 

P2 

P3 

P4 

P5 

P6 

P7 


© 


IC8 


SCL 

SDA 

Tnt 


PCF8574 


AO 

A1 

A2 


14 


15 




S 5 i 

6 15 

4 13 

12 

1 10 

l 9 

I 1 

— o o— 

— o o— 

11 

6m6 

o lo 

11 

I 

o 


2 

3 4 

5 

3 7 

8 


+5V 

■© 


3 

2 


5 6 


DIPSWO 


DIPSW1 


DIPSW2 


DIPSW3 


DIPSW4 


DIPSW5 


DIPSW6 


DIPSW7 


"N 

■\ 

"N 

"N 


TT.TTT 


R11 


9 


1 8x 10k 


+3V3 



2x 

FDV301N 


+3V3 


1 


SI 

n 


13 


+5V 

-© 


S2 


R5 


S3 

n 


R6 


S4 


R7 


SWITCH1 


SWITCH2 


SWITCH3 


SWITCH4 


A 

"N 

A 


R 8 


T T . T T 


R37 

+3V3 (+)— f T~ion~| 


K11 


K13 



7 

RESET 

8 


10 

LRCIN y 

11 

BCKINy 

12 

DOUT / 

15 

DIN jA 



C48 


lOOn 


K16 


z 


K17 


K4 


T 


V 


7777 


T 


V 


/ / / / 


V 


V 


7777 


Z 


O 

o 

CO 

n 

CN 

n 

i— 

n 

0 

n 


DC 

g 

OC 


z 

O 

1 — 

CN 

CO 

_l 

C/) 





a 

O 

X 

DC 

X 

DC 

X 

oc 

X 

oc 

O 

X 

X 

DC 

X 

oc 

X 

1 - 

O 

X 

X 

1 - 

X 

1 - 

X 

H 

X 

f— 

X 

H 

O 

0 


Q 

2 

LU 

—i 








DC 




1 - 












2 

4 

6 

8 

10 

12 

14 

16 

18 

20 

22 

24 

26 

28 

30 

32 

34 

36 

38 

40 


c 

!> d 

0 d 

d 

!> d 

5 d 

!> d 

!> d 

0 d 

d 

!> d 

\> d 

!> d 

!> d 

5 d 

d 

!> d 

5 d 


c 

!> d 

5 

c 

? 9 ^ 

? ? <i 

? 9 c 

? ? ^ 

? ? 

? ? c 

? ? ^ 

? ? <i 

? ? 

c 

j> ? 

1 

3 I 5 

7 I 9 

111 13 

15 1 17 

191 21 

23 1 25 

27 l 29 

31 1 33 

35 1 

37 

39 1 


22 


elektor electronics - 3/2006 













K12 


3, 5 


% 


7 1 9 




11. 13 


% 


15. 17 




19, 21 


3 


23, 25 


3 


27, 29 


3 


31 . 33 


3 


3 5 1 37 39 1 

O O O 


ooooooooooooooooooo 

OOQQQQQQQQQQQQQQQQQQ 




8 


10 


12 


14 


16 


//// 


18 


20 


22 


24 


26 


28 


O 

//// 


30 


32 


36 


38 


40 


//// 


+3V3 

© 


L3 


^C20 ^C21 ^C2 






FULLSPEED KBDDAT 




\ KBDCLK 




KEYBOARD 


MOUSEDAT 


A 


\ MOUSECLK 



MOUSE 


K7 


in 


CO 

04 



CO 

C4 



] 

04 

CO 



(D 

in 

CO 


G 

LU 

—1 

o 

LU 

_l 

Q 

LU 

-1 

G 

LU 

—1 

Q 

LU 

—1 

X 

O 

1- 

X 

O 

1- 

X 

0 

1- 

X 

0 

1- 

£ 

CO 

□_ 

§ 

CO 

Q_ 

£ 

CO 

□_ 

<i 

CO 

Q. 

<= 

CO 

Q_ 

£ 

CO 

□_ 

£ 

CO 

Q. 

£ 

CO 

Q_ 

> 

CO 

< 

> 

CO 

_l 

0 

CO 






5 

5 

s 

5 

Q 

G 

G 

0 

G 

G 

0 

G 

CO 






CO 

CO 

CO 

CO 











4 

6 

8 

10 

12 

14 

16 

18 

20 

22 

24 

26 

28 

30 

32 

34 

36 

38 

40 

!> d 

5 d 

\> d 

!> d 

) d 

!> d 

) d 

5 d 

\> c 

!> d 

!> d 

5 d 

) d 

5 d 

\> d 

!> d 

) d 

5 d 

!> d 

IS 

IS 

IS 

IS 

j> <j 

j> 

j> <j 

j> <j 

? c 

? <j 

? <j 

j> 

j> <j 

? <j 


<j 

j> <j 

j> 

? s 

3 1 5 

71 9 

11 

13 

15 

17 

19 

21 

23 

25 

27 

29 

31 

33 

35 

37 

39 


C24 


lOn 


33 n 


1 R 12 

TX CLK 


RXCLK 

■j ri6 

RXDO 

"j R17 

RXD1 


RXD2 

"! R20 

RXD3 


44 1 — 



43 


MDC 

42 


MDIO 

54 


TX ER 

56 


TX EN 

57 


TXDO 

58 


TXD1 

59 


TXD2 

60 


TXD3 

53 


RX ER 

49 


RX DV 

62 


COL 

63 


CRS 

4 


RESET 

64 



MDINT 


\ 

\ 

\ 

\ 

\ 

\ 

\ 

\ 

\ 

\ 

\ 

\ 

\ 


\ 

\ 

\ 

\ 

\ 

\ 

\ 


R29 



\ VGA HSYNC 

\ VGA VSYNC 


+3V3 

© 2x 

BAS40-04W 



IC7 

ULN2003AD 




LED1 

1 

f LED2 

2 

f LED3 

3 

' LED4 

4 

f LED5 

5 

f LED6 

6 

' LED7 

7 


V DIG 1 1 


Sv DIG 2 

2 

^ DIG 3 

3 

V DIG 4 

4 

V DIG L 

5 

\ DIG A 

6 

S. DIG B 

7 


\ DIG C 1 


\ DIG D 2 


\ DIG E 3 


\ DIG F 4 


\ DIG G 5 


DIG DP 6 




B1 

iv Cl 



B2 

C2 

B3 

C3 

B4 

C4 

B5 

C5 

B6 

C6 

B7 

C7 

E 

COM 


8 1 9 




IC10 

ULN2003AD 

B1 

iv Cl 



B2 

C2 

B3 

C3 

B4 

C4 

B5 

C5 

B6 

C6 

B7 

C7 

E 

COM 


8 1 9 




IC11 

ULN2003AD 

B1 

iv Cl 



B2 

C2 

B3 

C3 

B4 

C4 

B5 

C5 

B6 

C6 

B7 

C7 

E 

COM 


| D8 [D9 "d 10 Dll | D1 2 *D 13 |D14 

V->W>W'>W'>W>W'>W'>' 

|R21 | R22 | R23 | R24 | R25 | R26 | R27 

a r M I psl I /*v 1 pi I pJ I pi 

V] I ^ I v«/] V] I I Oi 

jo o I o I o o I o I o 

CM CM I CM I CM CM I CM I CM 


16 


15 


14 


13 


12 


11 



14 


+5V 


16 


15 


270 fl 




16 

1 R51 

13 

■j R52 

3 

■j R55 

5 

■j R57 

11 

■j R58 

15 

\ R59 

7 







D20 

1 

2 

6 

8 


A, LI 

B, L2 


T- CM CO q- -I 

< < < < < 

o o o o o 


L3 

o, 


rO 0*0 O 
■ UoLDJJJo 


G 

DP 


DIG1 


DIG2 


DIG3 


DIG4 


LITE-ON LTC-4627JR 








K2 

1 

3 

5 

7 

9 

d 

c 

) d 

p c 

5 d 

p c 

!> d 

p c 

!> d 

p c 

5 

p 


2 

4 

6 

8 

10 








K1 



-0- 


-0 



FEEDBACK 
VIN BOOST 

IC1 

LM2679-5.0 

SOFTSTART OUT 
ADJUST 


Cl 

lOn 


+5V 

© 

< 4A5 


LI 

15|jH 


1 


R1 


8 


5 

R2 


m 

CM 

00 



30BQ015 


C13 


22(i 

20V 


VIN 


Cl 4 


22ja 

20V 


C15 


22|m 

20V 


FEEDBACK 

BOOST 

IC2 

LM2679-3.3 

SOFTSTART OUT 
. ADJUST 


C16 


lOOn 


C9 

lOn 


+3V3 

-© 



8 


5 

R3 


D7 


m 

CM 

00 


CIO C11 C12 


180n 

6V3 


180(1 

6V3 


30BQ015 


180|i 

6V3 

050370- 11 


3/2006 - elektor electronics 


23 












HANDS-ON 


FPGA PROTOTYPING BOARD 


VGA 

Our prototyping board even has its own 
VGA output. The circuitry for this can be 
found around K9. Three super-cheap 
D/A converters are implemented using 
six resistors. The synchronisation signals 
can remain in digital form. As signal 
reflections can be expected here, all of 
these lines are protected against over- 
shoots by a set of fast Schottky diodes 
(D15-D19). 

Generating a VGA signal is easier than 
it appears. After reading the seventh 
instalment of the course, you'll know 
exactly how it's done. 


Ethernet 

The Ethernet interface is built around 
IC5, which converts digital signals into 
analogue signals and the other way 
around, all according to the Ethernet 
standard. Driving this interface is fairly 
complex. In the ninth instalment, 
well use this interface to perform some 
experiments on a network. 


7-segment 

displays 

The board has four 7-segment displays 
with decimal points, which are housed 
together with three separate LEDs in a 
single package (D20). This display has 
several common-anode leads (5 in total). 
They can be individually connected to 
the supply voltage to determine which of 
the five areas of the display should be 
illuminated. Here four of them are used 
for the four 7-segment displays and asso- 
ciated decimal points. The fifth lead pro- 
vides current to the three separate LEDs. 

The anode leads can be used to con- 
trol which elements of these five areas 
light up. 


For the drive signals, we use the same 
type of 1C as for the LED drive signals. 
Several outputs of 1C 10 and IC1 1 are 
used to switch the anodes to ground 
under control of the FPGA. Five leads 
are used to switch transistors T1-T5. In 
this way, we can use signals 
DIG1-DIG4 and DIG L to control which 
part of the display is active. 

Driving this display is somewhat difficult 
because the various parts of the display 
must be driven in rotation. We'll illus- 
trate how to do this in the second 
instalment of the FPGA course. 


Digital I/O 

We can easily imagine that the proto- 
typing board will be used as a control 
unit for something or other. There are 
eight digital I/O lines to allow user 
hardware to be connected to the proto- 
typing board. 

The 1C we selected for this purpose (IC4) 
has an l 2 C interface. This interface is 
also used to communicate with another 
1C that we'll describe shortly. 

The circuit around T8 and T9 has 
already been used in another Elektor 
Electronics design. It converts the 3.3-V 
l 2 C signals into 5-V l 2 C signals. 

The l 2 C bus uses a serial data transmis- 
sion protocol. The way this is implement- 
ed in the FPGA will be described in the 

third instalment of the course. 


USB 

A standard USB interface is built round 
connector K1 0. It can be optionally con- 
figured to present itself as a fast or slow 
USB device. The PC recognises a fast 
USB device by the fact that the D+ USB 
line is pulled up to the positive supply 
voltage by a resistor. For a slow device, 
the D- line of the USB is pulled to 
ground by a resistor. 


On the prototyping board, either option 
can be selected by the FPGA as desired 
by switching FETs T6 and T7 on or off. 
Here again, the two data lines are wired 
directly to the FPGA. 

We'll perform a few experiments with 

the USB bus in the eighth instalment. 


Analogue I/O 

Besides the digital I/O options, the 
board has four analogue inputs and one 
analogue output. These 8-bit I/O ports 
are provided by IC3, which also has an 
l 2 C interface. For that reason, this I/O 
option will also be described in the 
third instalment of he FPGA course. 


LEDs 

LEDs D8-D14 can be driven directly 
from the FPGA module by signals LED 1 - 
LED7. IC7 buffers the drive signals. 
Whenever an input is at a logic High 
level, the corresponding output is pulled 
to ground. The currents through the LEDs 
are limited by resistors R12-R27. 

This type of drive is very simple. In the 
first instalment of our FPGA course, 
we will use these LEDs to study various 
digital functions. 


Pushbuttons 

One of the input options of the proto- 
typing board takes the form of pushbut- 
tons. This is provided by pushbutton 
switches S1-S4. Signal lines 
SWITCH 1-SWITCH4 are held low by 
resistors R5-R8 when the pushbuttons 
are not pressed. If a pushbutton is 
pressed, the associated signal line is 
pulled up to the supply voltage. Signal 


24 


elektor electronics - 3/2006 









lines SWITCH 1-SWITCH4 are con- 
nected directly to the FPGA module, 
just like the LED signal lines. 

You can use the pushbuttons to control 
the states of four signal inputs to the 
FPGA. These four pushbuttons will also 
be used for simple input functions in the 
first instalment of the FPGA course. 


DIP switches 

Switch module S5 houses eight small 
switches, which are wired the same way 
as pushbuttons S1-S4. They allow an 
additional eight signal inputs of the 
FPGA to be controlled by the user. 

A good application for switches of this 
sort is to use them for enabling or dis- 
abling various options. We will use 
these DIP switches in the second 
instalment of the FPGA course. 


digital I/O lines. 

Well put the LCD through its paces in 

the fifth instalment. 


PS/2 

A PS/2 keyboard and mouse can be 
connected via connectors K14 and K15. 
Both signals on this bus are connected 
directly to the I/O pins of the FPGA 
module. As with most of the other I/O 
ports, the FPGA provides 'intelligent' 
control for these signals. Even the bidi- 
rectional data signal can be processed 
directly by the FPGA without the inter- 
vention of any external ICs. This commu- 
nication uses a special serial transmis- 
sion protocol, which well examine more 
closely in the sixth instalment. 



The "brains" on the Versatile FPGA Unit. 


Audio I/O 

The circuitry around 1C 12 forms a gen- 
uine 16-bit stereo input/output port. The 
sampling frequency is set to 48 kHz by 
the clock rate of IC1 3. 

This 1C communicates with the FPGA via 
five signal lines, which will be described 
in more detail in the fourth instal- 
ment of the course. Naturally, that will 
also include an example of an applica- 
tion in which the 1C is driven by the 
FPGA. 


LCD 

The 2-line by 16-character LCD (LCD1 
on the schematic diagram) is driven by 
IC6 and IC8. These ICs operate on the 
same principle as the ones used for the 


Power supply 

All of this is rounded out by the power 
supply. That's the only part of the circuit 
that isn't controlled by the FPGA. 

IC1 and IC2 are both step-down con- 
trollers. Each of these ICs forms a step- 
down converter in combination with an 
inductor, a diode and buffer capacitors. 
The advantage of these converters is that 
a high input voltage doesn't cause the 
supply to dissipate a lot of power in the 
form of heat, unlike a series-regulated 
power supply using a 7805 or the like. 

The input voltage on K1 can be con- 
nected either way round. D1 and 
D4-D6 sort things out so the polarity of 
the voltage at the inputs of IC1 and IC2 
is always correct. The electrolytic 
capacitors at the input ensure that fast 
switching currents stay on the board 
where they belong. As a result, the 
power supply generates relatively little 
interference. 

The FPGA is powered via K2. 

( 050370 ) 



The Ethernet interface built around IC5. 


3/2006 - elektor electronics 


25 










Qua&ar ElKiidfPCt Lmnited 

PO Bor 6935. Bishops Slortford 

CM23 4WP, Unite*! Kingdom 

T«£ 0370 240 1 E 326 

Fax: 0370 400 1045 

F nina 1 1 : sal&sigquasar steel rorucs. com 

Web: www.QuasarEJectrorncs.com 


PWW * K«i||h0 Optiftfli lUp -C 2K® BhWwtidnr UK ftt^rtclard 
1-7 Djy DcHmhv - Cj &5 UK MalviUAd Naxl Day Dallvvy - £§ ». 
Eufdpe | EUJ.£i;>: Rtsl yf World EL 9 95 |up !o 0 






!■* f**« ** N 


W* ucct|rf bH) nuiw c i , 1 1 r.-detift tard&. Mike cftaquw/PO’* pjyjbi-e 
td QuOUf Etecirontci Priced include- 17.5% VAT. 

Call f\*vt tiff ou f FflfE CATALOGUE with UkUiIs Of Crtwr KO ifciti, 
prdfHti, modulA-A and piifclKaliena. DlsefrUfils tot bull! u jarafcdH!^. 



QUASAR 

electronics 



Motor Ortv>rr‘C:ifit(ollwt 

Heine nr# jys.1 a tew of our eonlrollef and 
driver modules- for AC, DC. uni pofcar/bipolar 
stepper motors and servo motors Set 
websde ter full details. 



mm Bidirectional DC Meter Controller 

Control the speed of 
mosl Mimmgn DC 
motors (rated up to 
32Vd»‘5A,) in twfeh the 
forward and reverse 
directum The range 
of control is from fully OFF to telly ON in both 
directions The uiredion and speed are co ri- 
ff plied using a single potentiometer Strew 
terminal Uucfc for comediong 
Kit Order Code 3l«tT*tUM 
Assembled Order Code AS3166 - £23.96 

DO mt*t Spei 


Controller |IATl«Vf 
Control the speed of 
almost any common 
DC motor ratexi up Ip 
10CV/5A Pulse width 
mockjlation output tor 

rftaitimum motor torque 

at all speeds Supply 5-1 5Vdc B ox supplied 
Dimensions (mm) 6 QWkI00Lx 6QH 
hi! Order Code 3067 KT 111.95 
Assembled Order Code: AS3067 - £19.16 




PC t Standalone Unipolar 
Stepper Motor Driver 
Drives any 5, 6 or ELlead 
unipolar stepper motor 
rated up to 6 Amps max 
Provider speed and direc- 
tion control Operates in stand-alone or FC- 
conrtrolled nude Up lo sue 31 79 driver ‘boards 
can bt connected to a single parallel port 
Supply 9Vdc, PCB. 00x50 mm 
Kit Order Code 31 79KT - 1 1 1 .96 
Assembled Order Code AS3179 £18.96 

WW Bi-Poiai Stepper Moior Driver 
Drive any bipolar stopper 
motor uw rig exlemeily sup- . - *ji 

plied SV levels for stepping 
a nd direchon control. These 
usoa lly come fro m software 
running on a computer. 

Supply 8-30Vdc. PCS: 75x6Smm 
Kit Order Code 31 58KT - £ 14 .96 
Assembted: Order Code AS3159 - £27,16 




Most ate his are available in tall form (KT suffix) 
or assembled and ready for use (AS prefix), 


CREDIT CARD 

SALES 



17 71 



Cofrlroileri A Loggers 

Here are just a few of the controller and 
data acquisition and control units we have 
Sec website ter full details Suitable PSU 
ter all unite Order Cede PSU 345 £9 95 




Rolling Code 4 -Channel UMF Remote 
State -of-lhe-Art. Hiffh security 
4 channels Momentary or 
btching relay output. Range 
u p lo 40m Up to 1 5 Tx's can 
be learat by one Rx (kri in- 
eludes one Tan but more avail- 
able separately). 4 indicator LED V Rx PCB 
TTxfiSmm, 12Vd&‘6mA {sfandhy) Two end 1 
Ten chrintief ver&'orrs also OvSi ianl& 

Kit Orde r Code 31 80KT - £3196 
Assembted Order Code: AS3180 - £47.16 

Compute! Temp erai u re Data Logger 

4-channel* tempera! ure log- 
ger for serial port. *C or D F 
Continuously lo gs up to 4 
^eparaie sensora located 
2TOm* from board Wide 
range of free software appfi- 
cOtibins fqr -Stenn^uSiog data PCS pu$l 
3Ek38mm Powered by PC. Includes one 
DS182G sensor and four header cables. 

Kit Order Code 31 45KT - £ 1196 
Assembled Order Code: AS 3 145 - £23.96 
Additional D5I820 Sensors - £3,96 each 

uffy DTWf Telephone Relay Swilehei 
Cal! your phone number 
using a DTMF phone from 
anywhere in Ehm world and 
remotely turn on-uff any of 
the 4 relays as deared 
Uset sella bte Security Password, Ami- 
Tamper. Rings lo Answer, Auto Hang-up and 
Lockout includes plastic case Not BT ap- 
proved. t30xt10x30mm Power 12Ude 
Kit Order God# 3140KT - £33.96 
Assam tied Order Code A5314Q - £69.96 

&erial Isotated HQ Module 

Computer puntroiitd 6- 
channel relay board 
5A mams rated relay 
outputs 4 isolates.: 
digrtal tfiputS Useful m 
a variety of contra! and 
sensing applications. Controlled via serial 
port for programming (using our new Wm- 
dow&inte-rfape, lermmal emulator or batch 
files) Includes plastic case 1 34klOOi3^mm 
Power Supply: OVdc-EOOmA 
Kit Order Code: 310&KT - £49.96 
Assembled Order Code A331Q3 - £69.96 




Infrared R C Relay Board 
Individually control 12 on- 
board relays with included 
mfraned rarode central unit 

Toggle or mome-nta ry 1 5m * 
range It 2x1 22mm Supply: l2Vdfci‘£L5A 
Kit Order Code 3142KT - £39.9 6 
Assembled 0 r ^ m i cne, AS 31 A 2 - £ 49:66 



We have a wde range of low cosl FiC and 
ATMEL Programmers Gompiete range and 
documental on available from our web site. 

Progt&mmw Ac eMtflr/ 4 |? 

44 -pin WideZiF socket (ZIF40W] £l i.40 
ISVdo Power supply IRSU0 10) £19.9$ 
Leads: Parallel (LDC 136) £4 96 t Serial 
(LDC441) £4.96 / USB (LPC944} £2 J6 




mm* USB All-Flash PIC ProgmfnmaL 
USB PIC programmer For all 
'Flash 1 devices No external 
power smppty making it truly 
portable. Supplied with box and 
Wndows Software ZIF Socket 
and USB Plug A-B lead not ind. 

Krt Order Code 312SKT-E34J6 
Assembled Order Coda. AS31 2fl - £44.96 

■^ICALL" MC Programrrrai 

■PlCALL" will program virtu- 
aly all 3 to 40 pn ssnat- 
moere' ANDparaffeZ-moEte 
| PIC 16C5x family)* pro- 
grammed PIC micro cormol- 
lera Free fully functional software Blank chip 
auto detect for super fast bulk programming 
Parallel port connection Supply 16-18Vdc. 
Assembled Order Code AS31 17 - £24:96 

ATMEL 39-xxxx Programmer 
uses serial pert and any 
Standard terminal cpmms 
progra m 4 L E P 5 display 
the status. ZIF sockets 
not included Supply iS-lSVdc 
Kit Order Code 31 23KT - tUM 

USB 4 Serial Port FIC Programmer 
USB- Serial connection Header 
sable ter 1CSP Free Windows 
software Wide range of sup^ 
i ported PICs - see website for 
"oomptete listing ZlF SockeVUS© 
Plug A-B lead not md Supply: 16-1 SVdc 
Kit Order Code 3149CKT - £34.96 
Assembled Order Code AS3149C - £49.96 





www. q uasa r@ I ©ctroin ics.com 












Learn 


j 





A complete self-study course in using 
ARAAy microcontrollers 


*1 


a 




Keil UVISION3 IDE, C/C++ t6K compiler and, simulator 
Full Simulation of LPC20OO with peripherals, 
interrupts St uLINK JTAG interface Z Z 

■p 

Fully assembled LPCaixx 
development board 
Insider's Guide complete ARM7 
self-study course with 
CD-ROM based tutorial 



r 



■thj 




tirfaH. i.i.wn 






I 


LPC2129 

LPC2103 

LPC2140 

LPC2130 


WWW. 






hJ 


httex 


pfVR I (SrMfhl TfMHI 


"PHILIPS 



PicoScope 3000 Series 
PC Oscilloscopes 


The PictiSctipc 3000 striefi oscilloscopes arc the latust 
Offerings from the market loader in PC O&CilltiS topes 
combining hi|h handwidths with large buffer memories, 
listing the latest advances in electronics, the 
osciElascopeB connect to the USB port of any modern PD, 
mdhing full use of the PCs' processing capabilities, 
large screens and familiar graphical user interface 5 , 

* Biglh performance 1 : 10GS h ^ipnplmg rate 

& 300MHz bandwidth 

* IMS buffer* m v mo ry 

- Nigh . |..i l cj iJ U5£E S.Oi interface 

* Advanced display & trigger modes 

* Compact G portable 

■ Supplied with PicoScope & Pico Log software 


Tel: 01480 396395 

www. picotech.com/scope334 


11 1 


VI 


k 

fffl T'MiNi 

I'jir-i'i vib. 1 J .:iWm + 

t>lA b» 


!■»"■■■ >-i™ rlu »" 


(l | n jT.UJHa 


Qw>vm 
l‘L Cobp tcS 1 


Han 

lAii 


SDCHMIHi 

aiA* 

■iLHiMs 1 


Jwt*v\r Li !>□!■.■ IiiNn Ed i.n* *. 


K 

D Lhp QCUh. & 1 

hisitd 1H 

■ tlEh :i»k 

usua.d itAtfi ,i EipprtiHi 


1*6. ill Ed tiH\ ill 

0l« t^OMiir 


Tcr/ino/agy 


3/2006 - elektor electronics 


27 





INFO & MARKET 


DEVELOPMENT KITS 



In this issue, which is bursting with FPGAs and microcontrollers, they could not possibly 
be omitted: development kits! We devote attention to interesting but affordable kits 
where we not only look at kits that are suitable for a commercial environment but which 
are also very interesting for hobby use. 


The first few steps are always difficult. This is also true of 
course when working with FPGAs, microcontrollers and 
DSPs. Particularly in order to acquaint commercial devel- 
opers in an easy way with new products, various chip 
manufacturers offer so-called 'development kits' (some- 
times also called 'starter kits'). But if you would like to use 
them at home for yourself, then that is generally not a 
problem at all. You can usually just order a kit from the 
appropriate distributor for private purposes. There is then 
nothing to stop you from messing about with your chosen 
kit. The only catch is that you 'just' have to decide which 
kit you would like to get started with. And this can be 
much more involved than you would think at first glance. 
In this article we attempt to give you an overview of inter- 
esting and affordable kits. We selected a few kits from 
each category and have summarised the important 
details in a table. 

Options 

As already mentioned, before you start your development 
effort, you have to make a choice from the different 
options on offer from the various manufacturers. It is a 
good idea to not just consider what you need at this par- 
ticular moment, but also to think ahead about possible 
extensions you may wish to add at a later date. Imple- 
menting a small design in an FPGA is generally not a 
problem, but a larger design (i.e., more gates) can be 
more trouble to make fit. That is why development kits 
are often equipped with one of the larger members, if not 
the largest member, from a family. For microcontrollers 
too, it is good to take into account your future require- 
ments. Using fewer inputs and outputs is always possible. 
Wanting to use more than the 1C provides is impossible. 


Even the choice between an FPGA and a microcontroller 
may not be that immediately obvious. A microcontroller is 
less complex than an FPGA, but an FPGA, on the other 
hand, offers many more possibilities. 

The development boards have a number of inputs and 
outputs for communication with other devices (that they 
may potentially control). The RS232 port remains a very 
familiar interface. In many cases headers are used, so 
that every pin from the 1C can be accessed easily. Some 
boards have a number of ADCs and DACs and occasion- 
ally CAN, SPI and 1 -Wire-interfaces make an appear- 
ance. For programming, each board has its own specific 
connector. Microchip uses a so-called ICD programming 
interface, while others use RS232, JTAG or some other 
specific interface. The same holds true here: try to think 
ahead of what you may need at a later stage. 

In the large table we have included a number of critical 
characteristics so that it becomes relatively easy for you 
to make the final decision. 

Nevertheless, we will provide some guidance to the start- 
ing developer by describing the broad characteristics of 
microcontrollers, DSPs and FPGAs. 

Microcontrollers 

A microcontroller is essentially a computer in one chip 
(refer Figure 1). The arithmetic unit is integrated 
together with all the I/O and memory in one 1C, so that 
no additional chips are required (in contrast to a micro- 
processor which does need additional chips). Microcon- 
trollers are used mainly for controlling electronic equip- 
ment, such as, for example, our recent SMD Oven (see 
Elektor Electronics January 2006). 

The difference between an 8-bit and 1 6-bit controller is 


28 


elektor electronics - 3/2006 















J?CW«0CTOfl 


Lf i 


— 

9 



■ m - 


rli 

-»■ 

* 

i“* 



p.‘ 

WET 


j 

1 

i sTm.] 




mainly the speed. A 1 6-bit controller can, compared to 
an 8-bit controller with the same number of MIPS (Million 
Instructions Per Second), process twice as much data. 
Most of the demo boards have been designed in such a 
way that they can function on their own. That means in 
most cases that there is a microprocessor on the board 
that runs a (demo) program. In addition there is then the 
possibility to simu ate the board using the bundled soft- 
ware and, if the program is not quite 1 00 percent cor- 
rect, use debug-mode to iron out the last wrinkles. 

In the text box you can read some more regarding the 
choices for a particular type of microcontroller. 


DSPs 

DSP means Digital Signal Processor. Such a processor is 
really a kind of specialised microprocessor. The signifi- 
cant difference between a microcontroller and a DSP is 
that a DSP has been optimised for the mathematical oper- 


ations that are necessary for digital signal processing. 
For example, a DSP has a special register structure and 
mechanisms to carry out an FFT (Fast Fourier Transform, 
a mathematical operation to analyse the frequencies in a 
signal) as quickly as possible and to move large blocks 
of data as efficiently as possible. 

These days the boundary between DSPs and microcon- 
trollers is becoming increasingly blurred, for example the 
PIC series from Microchip. The microcontrollers are then 
provided with the partial functionality of a DSP (which 
means additional instructions). 

FPGAs 

An FPGA (Field Programmable Gate Array) is, as the 
name implies, a 'field' with programmable logic gates 
and programmable internal connections (see Figure 2). 
It is a real millipede. An FPGA can be programmed so 
that it carries out all kinds of logical operations. Ranging 


\Z 


RAM 



Configurable Logic Block 




FPGA 


I/O Buffer 


CLB 


CLB 


CLB 


PSM 


PSM 



/ 




CLB 

/ 

/ 

CLB 


CLB 


I/O Buffer 


050324-16 


Figure 1 . Block diagram for a typical microcontroller. 


Figure 2. Typical architecture of an FPGA. 


3/2006 - elektor electronics 


29 















INFO & MARKET 


DEVELOPMENT KITS 


Microcontrollers 

Manufacturer / 
Website 

Type of 1C supplied 

Programming 

Interface 

I/O 

LCD 

Power Supply 

R.R.P. 

PICDEM 2 Plus 

Microchip / 
www.microchip.com 

PIC18F452 and PIC16F877 

ICD 

RS232 

2x16 

standard 9 V DC 
adapter 

£59 

PICDEM 4 

Microchip / 
www.microchip.com 

PIC12F1320 and PIC16F627A 

ICD 

RS232; PIC16LF72 I/O expander 

2x16 

standard 9 V DC 
adapter; 9V battery 

£76 

DS89C450-K00 

Maxim/Dallas 
Semiconductor / 
www.maxim-ic.com 

DS89C450 

RS-232 

2x RS232; 4x 8-bit I/O 

- 

6-9 V DC adapter 

£62 

Z8 Encore! XP 4K Series 
Development Kit 

Zilog / www.zilog.com 

Z8F0XXA (selectable) 

USB or serial 

RS232; IrDA, header for ADC 
input (up to 8 channels), 

- 

5 V adapter supplied 

£35 

Z8 Encore! MCU 
Development Kit 

Zilog / www.zilog.com 

Z8FXX (selectable) 

USB or serial 

RS232, IrDA, header for ADC 
input (up to 8 channels) 

- 

5 V adapter supplied 

£35 

SK-XC866 Starter Kit 

Infineon / 
www.infineon.com 

XC866 

JTAG 

RS232, CAN, LIN, JTAG; Headers 
for motor control and SBC board 

- 

8-1 8 V adapter 

£100 

eCOGl Development Kit 

Cyan Technology Ltd / 
www.cyantechnology.com 

eCOGl 

Parallell port 

Fast Ethernet, parallel; debugger 
interface; 2x RS-232; \K, SPI, 

IrDA 

2x16 

adapter supplied 

£200 

AVR STK500 

Atmel/ www.atmel.com 

AT90S8515-8PC 

RS232 

2x RS-232; pin-headers for I/O 
ports of any AVR 

- 

10-15 V DC adapter 

£90 

R8C Starter Kit 

Elektor/Glyn / www. 

elektor-electronics.co.uk; 

www.glyn.com 

Renesas R8C-13 

R5F21 1 34FP#U0 

RS232 

USB; 2x serial port; LCD connnec- 
tion 

- 

via USB or adapter 

£62 

DSP's 








dsPICDEM 2 

Microchip / 
www.microchip.com 

dsPI(30F401 1 

ICD 

RS232; CAN; headers for all I/O 
ports 

2x16 

standard 9 V DC 
adapter 

£58 

Explorer 1 6 

Microchip / 
www.microchip.com 

PIC24FJ1 28GA01 0 and 
dsPIC33Fl 28GP71 ODSC 

ICD, JTAG and PICIcit 2 

USB; RS232, JTAG; headers for 
all I/O ports; PICTail Plus 

2x16 

9-1 5 V DC adapter 

£75 

MAXQ2000-KIT 

Maxim/Dallas semicon- 
ductor/ 

www.maxim-ic.com 

MAXQ2000 

JTAG 

RS232, JTAG, 1 -Wire interface; 
headers for all I/O ports 

41/2 

Via JTAG-interface, 

5V and 

6-9 V DC adapter 

£55 

FPGA's 








High Volume Starter Kit 
Bundle (comprising 
Spartan-3 Starter Kit and 
CPLD Design Kit) 

Xilinx/www.xilinx.com 

XC3S200-4FT256C (FPGA), 
XC9572XL-10VQ44C and 
XC2C256-7TQ144 (oolrunner-ll 
(CPLDs) 

JTAG 

RS232; JTAG; PS/2 mouse / key- 
board port, 3x 40-pin header 

- 

supplied 

75 

MAX II Development Kit 

Altera / www.altera.com 

MAX II EPM1270F256C5 (CPLD) 

JTAG via ByteBlaster 

USB; PCI; JTAG; Altera Expansion 
Prototype Headers 

2x16 

via USB- of PCI-bus 

£105 

ADDS-21 261/Cyclone 
Evaluation Kit 

Altera / www.altera.com 

Cyclone EP1C3 (FPGA) and ADSP- 
21261 (SHARC DSP chip) 

JTAG for FPGA, USB for 
SHARC 

USB; RS232; JTAG; expansion 
header 

- 

via adapter 

£140 

EasyFPGA's EZ1KUSB 
Development Kit 

EasyFPGA / 
www.easyfpga.com 

Altera ACEX EP1 K50TC1 44-3 

USB or JTAG 

USB; JTAG; 58 I/Os 

- 

via USB or supplied 
6V DC adapter 

£130 

Morph-IC 

Morph-IC/ 

www.morph-ic.com 

Altera ACEXEP1K10TC1 00-3 

USB 

USB; 2x20-pin header 

- 

via USB or supplied 
5V DC adapter 

£65 


30 


elektor electronics - 3/2006 






Devices Accepted 


Manual 


Software 


Required for programming Miscellaneous items supplied 


18-, 28,- & 40-pin PIC16XXXX 
and PIC18XXXX 


on CD 


MPLAB IDE, MPASM, MPLAB Cl 8 


PRO MATE II, MPLAB PM3, PIC- 
START PLUS or MPLAB ICD 2 


5k potentiometer, TC74 temperature sensor, piezo buzzer 


8-, 14-,& 18-pin PIC16XXXX 
and PIC18XXXX 


on CD 


MPLAB IDE 


PRO MATE II, MPLAB PM3, PIC- 
START PLUS of MPLAB ICD 2 


NanoWatt technology/supercapacitor circuit, four 5k potentiometer, 
space for LIN transceiver and motor driver 


DS89C430, DS89C440, 
DS89C450, DS5000 


on CD 


Microcontroller Tool Kit (MTK) 


Software only; PC (MTK) 


64kB Flash memory, 1 28kB SRAM 


not exchangeable 


on CD 


ZDS II Integrated Development 
Environment, ANSI C-compiler 


Supplied serial or USB Smart 
Cable 


256-1 k bytes RAM, 1 -4k flash memory, 2 16-bit timers, comparator. 
Optional: 8 channel 1 0-bits ADC, temperature sensor 


not exchangeable 


on CD 


ZDS II Integrated Development 
Environment, ANSI C-compiler 


Supplied serial or USB Smart 
Cable 


l-64k bytes Flash/ROM, 256-4k bytes RAM, up to 60 I/Os, up to 24 
interrupts, up to 4 1 6-bit timers, up to 1 2 channels 1 0-bit ADCs, 
optional: DMA controller, SPI and l 2 C. 


not exchangeable 


on CD 


Evaluation versions of Keil uVision and 
Ulink or Hitex debugger Tantino-Eco, 
DAvE 


Tantino USB (supplied) 


Compatible with 8051, PWM generator, 10-bit ADC, 3 16-bit timers, 
27 general purpose I/O, 768 bytes RAM, 16k flash, potentiometer 


eCOGl 


on CD 


CyanIDE with ANSI C-compiler, simula- 
tor, debugger and Configuration Tool 


Software only; PC 


2MB 16-bit SDRAM, piezo buzzeer, 12-bit ADC, temperature sensor 


8-, 20-, 28- and 40-pin AVR 
(Attiny, AT90S, ATmega) 


on CD 


AVR Studio 


Software only; PC 


2Mbit dataflash 


not exchangeable 


In Elektor / 
on website 


KD30, NC30, HEW, Flash Development 
Toolkit 


Software only; PC 


8-bit timer, 1 2 channel 1 0-bit ADC, 5 external & 1 1 internal inter- 
rupts, 4kB flash, 1 Ok potentiometer 



18-, 28- and 40-pin 
dsPIC30FXXXX 


on CD 


MPLAB IDE 


MPLAB ICD 2 


potentiometer, temperature sensor, nine 1 0-bits ADC channels, SPI 


PIC24 and dsPIC33 families 


on CD 


MPLAB IDE 


MPLAB ICD 2 


temperature sensor TC1047A, 10k potentiometer, 256kb EEPROM 


not exchangeable 


MAX-IDE 


Software only; PC 


MAXI 407 ADC/DAC, potentiometer, JTAG interface board, LCD board 


Spartan-3, Coolrunner-ll, 
XC9500XL 


On paper and CD- 
ROM 


Evaluation versions of Xilinx ISE & 
EDK 


Supplied JTAG3 cable 


3-bit, 8-colour VGA display port, 1MB SRAM 


not exchangeable 


on CD 


Quartus II Web Edition 


ByteBlaster II parallel download 
cable 


Temperature sensor, potentiometer 1 28kB SRAM, onboard power 
meterr 


not exchangeable 


on CD 


Evaluation version Visual DSP++, 
Quartus II Web Version 


Software only; PC 


64 Mb SDRAM, 64Mb EE memory, 4Mb Flash 


Altera ACEX EP1K10TC144-3, 
ACEX EP1 K30TC1 44-3, ACEX 
EP1 K50TC1 44-3 


on CD 


Quartus II Web Edition, USB-drivers 


Software only; PC 


not exchangeable 


on CD 


USB drivers, FPGA loader program, 
Windows DLL (for use with Visual 
C++, Visual Basic, Borland Delphi), 
Quartus II Software Starter Suite 


Software only; PC 


Onboard 93C56 EEPROM 


3/2006 - elektor electronics 


31 



INFO & MARKET 


DEVELOPMENT KITS 


from basic logic gate functions (AND, OR, XOR, NOT, 
etc.) to complex combinational logic such as mathemati- 
cal functions and decoders. It is even possible to emulate 
a complete (8051) microprocessor in an FPGA (provided 
that the FPGA has enough gates, of course). 

These ports are formed by CLBs, which are connected in 
a matrix arrangement. Each CLB consists of multiple 
lookup tables (LUT), a few multiplexers and optionally a 
number of flip-flops. So the CLBs carry out all logic func- 
tions. By connecting the CLBs with programmable 
switches to each other in the right way, the desired func- 
tionality is obtained. The development software generally 


sorts out these interconnections for you, so you don't 
need to do much there yourself. 

FPGAs have evolved from CPLDs (Complex Programma- 
ble Logic Device). As a consequence of their internal 
architecture, FPGAs have greater design flexibility com- 
pared to CPLDs. On the downside, the increased flexibil- 
ity has also increased the complexity. 

However, don't be taken aback by the overwhelming 
number of possibilities and accompanying data, descrip- 
tions, tutorials and other things. Once you've started 
with FPGAs, chances are that you cannot live without 
them any more. 

( 050324 - 1 ) 


The right microcontroller for every user 


Florian Schaffer 

The first steps into the world of micro- 
processors seem to be easy at first 
glance. Countless starter kits tempt the 
prospective buyer with all sorts of bells 
and whistles, but on closer examination 
they tend to be much alike. A PCB with 
a microprocessor, eight or more I/Os, 
an RS232 port for communicating with 
a PC and an LCD for the displaying of 
text is pretty much standard. So when 
choosing the hardware you cannot 
really go wrong that much. But which 
one do you choose? 

Apart from the differences in price, not 
too many things play a part when 
choosing a development kit for person- 
al use. If you are just starting out in the 
world of microprocessors and are 
about to buy your first kit, it is a good 
idea to first think about what you 
would like to achieve with the develop- 
ment kit and how much scope there is 
for expansion. Are you only going to 
design a specific control system for 
which the number of inputs and outputs 
are already defined? Are you just hav- 
ing a tentative look around and want 
to try things out in a microprocessor 
environment, do a little bit of program- 
ming for some flashing LEDs and react 
to pushbutton inputs, and get an LCD 
to spring into life? Or do you need 
some special functionality, such as a 
serial port, a USB-interface or an Im- 
port for data exchange with other 
devices? 

Depending on the purpose that you 
have in mind for the board, you will 
have to examine the various modules a 
little closer. It is best if you do not just 
rely on the brief technical datasheets 
from the manufacturer, but also look at 
the discussions in various Internet 
forums to read user experiences. In that 
way you get to find out the a particular 
board does have an RS-232 interface, 


but which is not very useful in real life 
because the 8-byte buffer is too small 
and the processor is much too slow to 
receive and process more than four 
symbols at data rates from 9600 baud 
and up. 

With this we arrive at the next criteri- 
on: instruction set and speed of the 
processor. For a heating control appli- 
cation there is no need for the CPU to 
calculate at great speed. If it gets 
warmer a few seconds later, then that 
is not a big deal. It is different if a few 
thousand LEDs have to be driven via 
some multiplex scheme. If the CPU is 
not fast enough, the LEDs will just 
appear to flash in some meaningless 
fashion. If your program has to react 
quickly to signals Trom the outside', for 
example keyboard input or data from 
an interface, then it can be handy if 
the microprocessor is good at process- 
ing interrupts. 

Also think about the various program- 
ming solutions. Do you need additional 
hardware to program the microcon- 
troller, can it be (re-) prog rammed in the 
system (ISP - In System Programming)? 
What method do you prefer? 

What are your ambitions regarding tin- 
kering with these things? Most develop- 
ment kits consist of one PCB. The LCD 
is connected with a ribbon cable and 
the power supply consists of by a stan- 
dard mains adapter, which is regulated 
on the board with a 780x. With very 
simple models it may even be possible 
that you have to provide your own reg- 
ulated power supply. 

Perhaps you're looking for something 
to do some control tasks in your home. 
A module that has been designed for 
rail/rack mounting, typically used in 
electrical installations, can be very 
practical. In order to realise your 
plans, it is probably necessary that you 
need more parts, which you will have 
to build yourself or that are possibly 


available read-made. Examples are a 
stepping motor driver or a relay board 
to control large loads. 

After you have made your selection 
with respect to the hardware, do not 
forget to look at the software aspect. 

Of course, for most of the microproces- 
sors some form of development environ- 
ment is available. The question is, how 
much do you have to pay for it, and 
with which programming language do 
you have to work? Assembler is not 
something everyone is familiar with. C 
and BASIC are easier for beginners to 
use and are certainly not worse, 
although hardcore assembler hackers 
will sometimes have a good laugh 
about BASIC. The resulting machine 
code ultimately loaded into the proces- 
sor is not substantially different com- 
pared to handwritten code. Because in 
the beginning you will probably need 
to rely on some help from other users, 
it is best to have a look for a suitable 
forum and see what sort of topics are 
being discussed. The best way is to use 
Google to search for forums that deal 
with a specific type of controller. 

It is possible that a development kit 
contains a programming language that 
in practice is not actually used in com- 
bination with that kit, for example a C 
development environment. If you have 
questions in relation to that, it will take 
much longer to get an answer if other 
users use predominantly BASIC or 
assembler. 

In the forums there are always people 
participating who are glad to help you 
out. Most of the beginner's questions 
have already been asked so it certainly 
pays to do a search of the forums first. 
In general you have to be prepared to 
do a little searching to obtain a satis- 
factory end result. You will also have to 
trawl through numerous datasheets. 


32 


elektor electronics - 3/2006 



Your price conscious PCB supplier 




CIRCUITS 


Online price calculation 
Online ordering 
Online order tracking 
Online 24/24H and 7/7D 


a la 


carte 


Interested? Contact us: +32 15 28 16 30 
E-mail: euro@eurocircuits.com 

www.eurocircuits.com 



pooling for standard boards 
up to 6 layers 
from 1 to 1000 pieces 
from 4 working days onwards 


- technology at the right price 

- up to 8 layers 

- from 1 to 1000 pieces 

- from 3 working days onwards 


your board, our challenge 
up to 20 layers 
from 1 piece onwards 
from 2 working days onwards 



Tel: 01635 40347 

he m *» 3*1 

(-null: oilj I sCnrwtkrY-lEtni eg 


Nnwhuiy Ehtftraish:* lid 

FraJtymgd He***? 
mm JwrtHffYEtocb me s ek. u t 





Lichfield Electronics "Hr 

Tel: (01543) 256684 Web: www.lichfieldelectronics.co.uk wsi3 6ju 



Line Tracking Mouse £24.99 

Uses an 8bit OTP CPU and 
photo transistors to follow a line. 

Sound Reversing Car £13.75 

Using a mono-stable oscillator & 
mic this car will react to sounds. 

Transistor Radio £9.99 

BSr A small AM radio with ZX141 
IC. With headphones. 

Basic Solar kit £6.99 

This kit includes a small solar panel. 

“solar” motor, stickers & booklet. 

10 LED Flasher £4.99 

Make an astable oscillator which 
flashes two sets of five LED’s 

Photo Sensor & Relay £6.99 

Make a kit that can turn an item 
on or off when it goes dark 

Metal Detector kit 

How does a metal detector work? 
Find out with this great kit. 


M 



Uli U1 UII V 



£9.99 


13 Note Electronic Organ £4.99 d 

Make lots of noise with this 
great kit based on the 555 chip, m 




When it goes dark this fly 
will sing a happy tune. 

We Also stock a range of lead free logic chips... 


• 'Vi 





Electronic Dice £6.99 

Using a 555 and a 4017 chip 
make an electronic dice. 

Shortwave Receiver £9.99 

Using this kit you can listen to * f# 
amateur radio through a speake' 

FM Microphone £12.99 

Build a short range FM 
transmitter with microphone. 

Crystal Radio £7.99 

This is a great postcard 
AM crystal radio. No soldering 

Single Valve Radio £26.99 

Build your own thermonic 
valve AM radio. No soldering. 

Infrared player £14.99 

A two part kit which plays 
music based on what button 
is pressed on the remote. 

Light Alarm £4.99 
Using transistors, when this kit 
sees light it makes a noise. 

Music Firefly £8.99^^ 






soldering. 

IB 


-i 1 H 


Tilt 



Aoyue 909 Rework Station £99.99 

This great surface mounted rework station 
includes a 35W 200-480C temperature 
controlled soldering iron, 100-500C 
Hot air rework gun, 4 nozzles and a 0-15V 
1 .5 A PSU. A must have unit! 



Aoyue 936 Soldering Iron £24.99 

A high quality temperature controlled 
35W soldering iron with long lasting 
ceramic heater element, metal iron stand 
with solder holder/feeder. Spare element 
included free! Temp range: 200-480C 


Other tools and such Babani Books & More 


Coil Design and Construction Manual £3.99 

IC 555 Projects £4.99 

25 Simple Indoor and Window Aerials £1 .75 

25 Simple Tropical and MW Band Aerials £1.75 
Getting the Most From Your Multimeter £3.99 
An Introduction to Amateur Radio £4.99 

How to Use Oscilloscopes £6.99 

Projects for Radio Amateurs and SWLs £3.95 
The Art of Soldering £3.99 

A Beginners Guide to TTL Digital Ics £4.95 
A Beginners Guide to CMOS Digital Ics £4.95 
Practical Opto-Electronic Projects £4.95 

Electronic Projects for Video Enthusiasts £4.95 

Nuts & Volts US Electronics Magazine £4.99 


Aoyue 850 hot air gun 

£54.99 

Smoke Extractor 

£34.99 

Workstation & PSU 

£27.99 

Aoyue suction pen 

£3.50 

2M Pb Free Solder 

£1.99 

4M Pb Free Solder 

£2.99 

35M Pb Free Solder 

£7.99 

Advanced Kits 


AM Radio Kit & Case £13.99 
AM/FM Radio & Case £16.99 
DIY Multimeter Kit. £16.99 
Multi-Output PSU kit £17.99 
100ft TV Transmitter £27.99 


Post and Packing 


HEF4001BP: Quad 2-Input NOR-Gate DIL-14 29p 
HEF4011BP: Quad 2-Input NAND-Gates DIL. 29p 
HEF4013BP: Dual D-Type Flip-Flop DIL-14. 29p 
HEF4015BP: Dual 4-Bit Register DIL- 16. 43p 

HEF4017BP: 5-stage Johnson Counter DIL-16. 38p 
HEF4021BP: 8-Bit Stat Shift Register DIL-16. 43p 
HEF4028BP: 1 -of- 10 Decoder DIL-16. 40p 

HEF4060BP: 14-Stage Binary Counter DIL 45p 
HEF4069UBP: Hex Inverter DIL-14 29p 


SN74HC00N: Quad 2-Input NAND Gate DIL 25p 
SN74HC02N: Quad 2-Input NOR-Gate S DIL 25p 
74HC03N: Quad 2-Input NAND Gates DIL-14 29p 
74HC04N: Hex Inverter Buffered-Gate DIL-14 26p 
74HC08N: Quad 2-Input AND-Gates DIL-14 26p 
74HC10N: Triple 3-Input NAND Gates DIL 29p 
SN74HC11N: Triple 3-Input Flip-Flop DIL-14. 25p 
SN74HC14N: Hex Inverter CMOS DIL-14. 23p 

74HC21N: Dual 4 Input AND Gate DIL-14. 29p 


SN74HC74N: Dual D-Type Flip-Flop DIL-14. 25p 
SN74HC245N: Octal 3-State Bus Transceiver . 42p 

SN74LS00N: Quad 2-input NAND-Gate. 50p 

SN74LS14N: Hex Inverter Bipolar DIL-14 50p 

SN74LS32N: Quad 2-Input OR-Gate DIL-14 46p 
SN74LS123N: Dual Mono-stable multi-vibrator 65p 
SN74LS138N: 3-to-8 Line Decoder DIL-16 65p 
SN74LS245N: Octal 3-State Bus Transceiver 76p 
SN74LS373N: Octal D-Type Latch DIL-20 76p 


Order Value 

£4.99-£12.99 

£13.00-£22.99 

£23.00-£49.99 

£50.00-£150.00 


P&P Cost 
£1.50 
£2.50 
£6.00 
£12.00 


UK Only, phone for P&P to Ireland. 
Pay by cheque, card or postal order! 
Visit website for weight based P&P 

Or visit our shop in Lichfield 


3/2006 - elektor electronics 


33 











INFOTAINMENT 


THE 6502 


The Triumphant March 

30-year old design still inspires thousant 

Roelf Sluman 

Are eight-bit processors something from the past or is it still possible to do some- 
thing useful with them? Elektor Electronics went looking and discovered that the 
good-old 6502, in a world of threaded computing and dual-core processors, still 
has a following of faithful fans. 


Figure 1. 

The KIM-1 computer, 
developed by MOS 
Technology. Input was 
via a hexadecimal 
keyboard, for the 
output a 6-digit LED 
display was present. 


In the 1970's and 80's three 8-bit processors dominated 
the market: the 6809 from Motorola, the Z80 from Zilog 
and the 6502 from MOS. By far the most popular of 
these three was the 
6502: its low cost (when r — 
introduced, the 6502 set 
you back about 25 dol- 
lars) and the advanced 
design for its time made 
sure that the 6502 con- 
quered the world in a 
short time as the brain in 
popular home-computers 
such as the 

Commodore 64 and the 
Apple II. 


elegant 8-bit processor. Many thousands of enthusiasts 
across the whole world still work daily with the 6502 
and make it do things that were not considered possible 

1975. 


in 


Price war 


When the 6502 was introduced In 1975 it cost 
about 25 dollars. That made it a serious com- 
petitor to the processor it was copied from, the 
6800, which by comparison costs a whopping 
1 79 dollars. No wonder computer manufacturers 
such as Apple and Commodore went for the 
6502. Steve Wozniak from Apple had his eye in 
the 6800, but the enormous price difference ulti- 
mately forced the decision. 


We are now some 30 
years later and proces- 
sors that are many thousands of times faster than the 
6502 now dominate the market. But... that does not 
mean that there are no applications to be found for the 


tylODULf 

rr 



hUt \Vjlk ^ 


r- 


,T . 



History 

The 6502 processor cele- 
brates its 30^ anniver- 
sary this year. The intro- 
duction was preceded by 
a scandal: the designers 
of the 6502 had, in the 
first instance, developed 
another processor: the 
6501. Unfortunately, it 
was a virtual copy of the 
— _ — — _ — _ j 6800 processor from 

Motorola. This is not a 

surprise, because the same designers developed the 
Motorola 6800! Shortly after the 6800 processor 
appeared on the market, a dispute arose between 
Motorola and the 6800 designers. This conflict resulted 
in the resignation of most of the designers, who were 
promptly hired by MOS Technology (in the 70's 
Motorola's biggest competitor). MOS recognised the 
potential for the 6800 and asked the designers to design 
a processor that was pin-compatible with the 6800. That 
became the 6501 , which was much cheaper because the 
development costs were negligible. 

Naturally, Motorola weren't going to just let that happen 
and threatened to drag MOS into court. MOS responded 
with the 6502, which was exactly identical to the 6501 
with the only change that the pin-out was different. As a 
consequence, the 6502 no longer fitted in boards that 
were designed for the 6800, which was reason enough 
for Motorola not to proceed with a lawsuit. 

Because there were now no boards that would fit a 
6502, MOS had to design something to bring the 6502 


34 


elektor electronics - 3/2006 







the 

Is of designers 


to the attention of software developers. This 
became the KIM-1 (see Figure 1), a single-board 
computer with 1 kB of RAM. 

Computer manufacturers quickly appreciated the enor- 
mous potential that the 6502 offered. With the introduc- 
tion of the Apple II and Atari 400 personal computers, 
the 6502 broke into the American market; Commodore 
was equally successful in Europe with the VIC-20 and 
later the Commodore 64 (with a more advanced version 
of the 6502, the 6510). The sales of just the Commodore 
64 alone exceeds 25 million; the total number of 6502 
processors sold worldwide is estimated at well over one 
hundred million! 

In Elektor Electronics there were also countless projects 
using the 6502. The 'Junior Computer' was an exception- 
ally successful learning system published in the 1980s. 
From 1 983 there was a series of boards that allowed 
you to build a complete 6502 computer. This finally 
resulted in 1 985 in a system that was called Octopus 65. 

The technology 


puter with 64 kB of 
memory that could be 
switched in or out as 
desired in an intelligent 
manner, via a method called bank switching.. (For 
example, in the memory area into which the I/O ports 
were mapped there was also a section of RAM that could 
be switched into 'view' so that data could be copied to it 
and then switched 'out of view' so that the l/O-ports 
were accessible again.) 


Get cracking yourself with a 6502 

The best way to get to know the 6502 is to work with 
one yourself. 


Simulator 

The easiest way is using a simulator, a piece of software 
that imitates the behaviour of a 6502. An example of an 
excellent 6502 simulator is the program 6502 Simulator 
that you can download free from 

http://home.pacbell.net/michal_k/6502.html (Figure 2), 
among others. 


The 6502 is a 5-volts, 8-bit processor with a 1 6-bit 
address bus, that with a range from 0x0000 to OxFFFF is 
able to address up to 64 kB of memory. It comprises 
4,300 transistors. The clock speed is 1 MHz, but 
because the 6502 does not have to work through a list of 
microcode instructions for each opcode that has to be 
executed, it is in practice just as fast as a 4 MHz Z80 
(which does use microcode). 


Emulator 

An emulator is a computer program that creates a so- 
called virtual machine: a computer inside a computer as 
it were. Because an emulator is a software replica of an 
authentic computer or processor, all software written for a 
certain computer or processor will also run in the emula- 
tor. Even possible design faults that were present in the 


The instruction set consists of no more than 56 instruc- 
tions and because RAM memory was much faster in 
those days, the designers saved on internal registers. The 
6502 has therefore only three, each eight bits wide: the 
accumulator (the only register on which operations can 
be performed), and the index registers X and Y. The rela- 
tively large number of addressing modes of the 6502 
makes it possible to address 64 kB of memory efficiently, 
using two-byte instructions (opcode and one operand). In 
order to fill 64 kB of memory, not more than 1 9 bytes of 
opcodes and operands are required. (Do you know 
how? Send the author an email: rsluman@gmail.com!) 

There exist a number of variations of the 6502, with 
either more or fewer features. The best known are the 
6507 (which was used in the Atari VCS2600 game com- 
puter) and the 65 1 0 that can be found in the Com- 
modore 64. The Commodore 64 was the first home com- 



Figure 2. 

Ideal for those who 
want to work with a 
6502: the 6502 
macro-assembler and 
simulator from 
Michal Kowalski. 


3/2006 - elektor electronics 


35 







INFOTAINMENT 


THE 6502 


Figure 3. 

The old, trusty screen 
from the Commodore 
64, now as emulator on 
a modern computer. 



original hardware are present in the emulator! 

Practically every computer from the 70's and 80's has 
been emulated by now. In a large number of cases, the 
software producers from the then popular computer soft- 
ware have made their software freely available for use on 
these emulators. If you're ever thinking nostalgically about 
your time in front of your Apple, Atari or Commodore com- 
puter then you can relive those times with an emulator! 

One of the better-known emulator programs is VICE (a 
rather silly abbreviation for Versatile Commodore Emula- 
tor). This can be found at www.viceteam.org. VICE was 
written to emulate all known Commodore home computers 
(including the Commodore 64). The VICE emulator is so 
perfect that practically every piece of software ever writ- 
ten for the Commodore 64 runs flawlessly under VICE. 
After starting VICE, the famous blue screen of the Com- 
modore 64 appears (Figure 3). From now on you're 
dealing with a real Commodore 64. Even the keyboard 


Figure 4. 

One of the two PCBs 
that comprise the 6502 
built from discrete 
parts by Dieter Muller, 
(source: website 
Dieter's Hobby 
Projects) 




e 

& 

mb 



l5" v 1 w ^ • 

,Y ■- ■ 

- V - h in - 




Figure 5. 

At FPGA Arcade 
various 6502 hardware 
for games are emulated 
in an FPGA. 



has been arranged differently and now corresponds to 
the Commodore 64 keyboard. The disk drive and cas- 
sette player, including any possible turboloaders are also 
completely emulated. 


Copying 

You can also copy a 6502 using 'discrete' components 
such as 7400-series ICs, RAMs and EPROMs. This is 
what Dieter Muller did with some old bits he had at 
home. He nearly succeeded, using about 40 ICs and two 
PCBs (Figure 4). The most important concession is a dif- 
ferent timing, but his processor knows all 6502- and 
65C02 opcodes (see http://people.freenet.de/ 
dieter.02/ m02.htm). 

A different approach is to start with an FPGA and to 
build into it the complete functionality of a 6502. An 


36 


elektor electronics - 3/2006 













FPGA, after all, contains a large number of programma- 
ble logic blocks and in a modern version the circuit for 
an 6502 can be easily accommodated (or even multiple 
copies in one FPGA!). There is an organisation, which 
goes by the name Opencores, that is engaged in the 
development of various CPU cores in FPGAs 
(http://opencores.nnytech.net). The 6502 code can be 
found after a bit of searching, it is called T65. This is also 
available from http://www.fpgaarcade.com/, where 
a number of games variations of the 6502 are available 
as well (Figure 5). 

Applications 

Because the 6502 is such a versatile and cheap proces- 
sor, and because it is easy to combine with other hard- 
ware, it is still a favourite element in many DIY projects. 
Many projects can be found on the Internet that use a 
6502. Most of these comprise a home-built computer 
with the 6502 as its nerve centre, but a number of very 
inspiring applications can also be found... 

The 6502 in the casino 

That a 6502 can be used to make a lot of money was 
discovered by the / Eudaemons / , a pair of American stu- 
dents from California. They built two circuits based in the 
6502, which they housed in two shoes. They subse- 
quently went to a casino and picked a roulette table. Stu- 
dent number one moved his shoe in the same rhythm as 
the revolutions of the roulette wheel. The 6502 processor 
in this shoe used a revolutionary algorithm to calculate 
on which number the ball would come to rest. This infor- 
mation was then automatically sent to student number 


2 kB memory? 
More than enough! 

The first computer in which the 6502 was used 
was the world famous games computer from 
Atari, the VCS2600. Although the 6502 was 
already the cheapest computer in its class. Atari 
managed to reduce the price even further by 
ordering a special version of the 6502, the 6507. 
This processor could address a maximum of 8 kB 
instead of the normal 64 kB. Not a problem, 
according to the designers of the Atari 2600. 
After all, memory was so expensive that no com- 
puter game would ever use more than 2 kB. 


two, who could determine, based on the vibrations in his 
shoe, on which number to bet. 

Give your robot eyes 

Mike Naberezny used a combination of four Sharp 
GP2D02 infrared sensors and a 6502 to give his robots 
'eyes'. The program does nothing more than continually 
poll the four sensors (high values mean 'close' and low 
values mean 'far') and pass this information to the robot. 
On the Internet (with as starting point www.6502.org) 
many more such fantastic projects around the 6502 can 
be found. 

(050316-1) 


Where can you find 
a 6502 now? 

Gunther Ewald 

It is hard to believe, but microcontrollers with a 
6502 core are still being produced today. 

Manufacturers such as Micronas and Renesas use 
this CPU core in cheap microcontrollers for simple 
control tasks. 

Have a look at Micronas at the WDC65C816 CPUs, 
which are used mostly in automotive applications: 

http://www.micronas.eom/products/by_function/c 
dc_l 607f-e/product information/index. html 


Renesas employs the 6502 core in the entire 740 
family. These are (with exception of specific exten- 
sions) completely opcode-compatible with the origi- 
nal. 

Unfortunately the selection has been reduced 
somewhat as a result of switching to lead-free pro- 
duction, but the manufacturer still has 37 deriva- 
tives with a 6502-core: 

www.renesas.com/fmwk.jsp7cnts740_family land- 
ing.jsp&f p=/ products/ mpumcu/740_family/ 




■ II 

IS* 

mkm 

Lfiri 


uj frtuj; s h | \yt iwm i ft 

S *! 1 

kMUILl 


tor i Bin 


£: 4 - 

! X: 1 




14- — 


These products are not really suitable for hobby 
applications. You need to use a special emulation 
MCU and an emulator. The manufacturer does 
make a free MCS-simulator available with a run- 
time of 4 months. This offers l/O-simulation, inter- 
rupt-simulation, execution cycle measurement, RAM 
monitor display and coverage measurement. The 
program is available from the Renesas homepage. 


3/2006 - elektor electronics 


37 


HANDS-ON 


MICROCONTROLLERS 



Gunther Ewald 


and Burkhard Kainka 



In the February issue, we 
described how you can get 
started with the R8C/13 
microcontroller module without all too 
much effort. The application board 
described here gives the module a 'base camp' 
with lots of connections to the outside world, 
including a USB interface and two serial ports. There's also an LCD interface and other 
useful features for developing your own applications. 


38 


elektor electronics - 3/2006 






















The starting point for this design was 
the question, what do you need to suc- 
cessfully utilise all the major features of 
the microcontroller with a minimum of 
effort? The result is a circuit board with 
the following complement of functions: 

• two serial interface ports 

• a USB port using an integrated 


USB/serial adapter 

• an LCD interface 

• four LEDs that can be connected to 
port lines 

• a potentiometer connected to one of 
the many analogue inputs 

• a power supply socket and 5-V volt- 
age regulator 

• an option for powering the board via 


the USB port 

• a reset switch 

• a jumper for the MODE input 

The USB interface on the board deserves 
special mention. Serial interfaces are 
becoming increasingly rare on new PCs, 
but asynchronous serial interfaces are 
fundamentally necessary for communi- 


D5 

1 N4002 


IC2 


K1 

-rr 

\ < 

r\ 



CIO 

220|i 

25 V 








7805 

0 » 


C11 


lOOn 


+5V 

© 


+5V 

© 


+5V 

© 


C12 

lOOn 


JP11 

POWER 

fo Q ofr 


EXT 


Cl 3 


10|Ll 

16V 


USB 


FI 


+5V 

© 


Polyfuse 


+5V 

© 


PI 


100mA 


JP12 



© 

+5V 


z 


JP1 



ANALOG 

7 

j 

10k 

+5V 

n 


(+) 




R9 


H D2 JP4 

-&1 



SERIAL 

PROGRAMMING 
KA 


LJ K5 


K6 


©- 

+5V 


r\. 

RXD1 1 

_r\ 

KS 

rv. 

CNVSS 1 

_C\ 

_r\_ 

RESET 1 


V-/ 

rv 

XOUT 1 


_r\. 

VSS 1 


V-/ 

r\. 

XIN 1 

vj 

{ U~ 

_r\ 

VCC 1 

vJ 

m r\ 

■U" 

r\_ 

PI. 7 1 

_r\ 

\~r 

r\. 

PI. 6 1 


V-/ 

RXDO 1 

vJ 


TXDO 1 

vJ 

■v-r 

_r\_ 

PI .3 1 

_r\ 

V-/ 

PI .2 1 



P1.1 1 


r 

_r\ 

P1.0 1 


V-/ 

rv 

P4.5 1 



1 



16 


RXDO 


RXD1 



SUB D9 9 


SUB D9 9 


Cl 4 




4|i7 

25V 


14 


13 


Cl 7 


is 


4|i7 
25 V 



Cl 5 
4p7 

m 


Ul 

25 V 

2 

v+ 

C1 + 

© 

IC3 

Cl- 


TIOUT 

T1IN 

RUN 

RIOUT 

R2IN 

R20UT 

T20UT 

T2IN 

C2+ 


MAX232 

C2- 

J- 

V 



+5V 

© 


16 


11 


12 


10 


15 


Cl 6 

■IQ- 

4|T7 

25V 


C2 


lOOn 


~l 


K7 


32 


17 


a 


o 


o 


o 


o 


TXD1 


1 P0.1 

1 P0.2 

1 P0.3 

1 MODE 

1 P0.4 

1 P0.5 

1 P0.6 

1 P0.7 

1 IVCC 

1 P3.0 

1 AVSS 

1 P3.1 

1 AVCC 

1 P3.2 

1 P3.3 


O 


O 


o 


o 


I I 


TXDO TXD1 


USB 


K4 


JP7 

a 

o 


K4 


JP8 

O 


USB 


USB 


o 


(3 

O 

EC 

a. 


JP9 

a 


K4 


o 


K4 


JP10 

a 


USB 


5 

V) 


R6 


RIO 


R11 


R17 


K8 LJ U 

o 


JP2 

PROG 

+5V 

© 


K9 


LCD 


B 


P2 

V 


CONTRAST 10k 


10 


11 


12 


13 


14 


LlOOn 


O 


O 


O 


VSS 

VDD 

VO 

RS 

R/W 

E 

DO 

D1 

D2 

D3 

D4 

D5 

D6 

D7 


to 

X 

CM 

a! 

</) 

Q 

O 

-j 


+5V 


J- 

2 


100n 


12 _ 

13_ 

14_ 

2 _ 

3_ 

6 


26 


7 

21 


8 


17 


24 


TXD 

RXD 


Q co 
52 o > 

C4 > ", 

J a' 

a 
> 


a 

a 

> 


SHTD_N 
EE_CLK 
EE DATA 


IC1 


\ RST 
J VDD 

DSR_N 
DCD_N 
CTS N 


PL2303 


DTR_N 

RTS_N 

RI_N 

PLL_TEST 

GND 

GND 

OSC1 


DP 

DM 

TRIMODE 

LD_MODE 

GND_PLL 

GND_3V3 

OSC2 


C6 


lOp 


27 


XI 


I I 


12MHz 


19 


20 


R13 


10 R14 


11 


R12 


\ 220k | — '» 
\ 220k 


15 


16 


\ 220k 

R16 

-\ 27 (> |~ 


22 


23 


25 


18 


28 


C5 


lOp 


R15 


27 Q 


R5 


0 


n 

Jl6V pi 

X 


J" 

L^p6V 

X 


C8 


lOOn 


K2 


O O 
O 0 


6 4 


USB-B 


050179-3- 11 


Figure 1. The circuitry on the application board provides two serial ports, a USB interface and an LC display to connect the R8C daughter board to the outside world. 


3/2006 - elektor electronics 


39 


HANDS-ON 


MICROCONTROLLERS 


USB Port 



050179-3- 12 


Figure 2. Block diagram of the 
Prolific interface converter. 


cation with the microcontroller. For that 
reason, we decided to simply include a 
USB/serial adapter on the board. 

In contrast to the equally viable 
approach of using an external USB 
adapter, this has the advantage of 
allowing the board to be powered via 
the USB port. A total of four jumpers 
determine which serial interfaces of 
the microcontroller are routed via the 
RS232 ports or the USB port. For 
instance, you can load and debug pro- 
grams via the USB interface, or you can 
use the USB interface for serial commu- 
nication with the microcontroller and 
your programs. 

Microcontroller ports 

The schematic diagram (Figure 1) 
essentially shows the principal fea- 



- - “ a* i* f* ML ■ . x a 


J *-**.•. ;r 

| -rill mT 
.r ir^fc 
j .^irr an 1 ■ 

■ ■ -J 

iuLUubu 
f hL- i- 
J MhM 





Figure 3. The virtual COM interface in the 
Windows XP Device Manager window. 


tures of an R8C system as already 
mentioned in the February issue. The 
MODE jumper and Reset switch are 
important features. Interface drivers 
are also necessary for the RXD1 and 
TXD1 leads of the debug interface, 
which are routed here via JP7 and JP8 
to allow either RS232 or USB to be 
used. Depending on the jumper set- 
tings, you can use either the MAX232 
and connector K4 or the PL2303 USB 
controller and a USB link. 

In addition to the serial debug inter- 
face (UART1), the R8C/13 has a sec- 
ond, fully independent serial interface 
(UARTO) that communicates via the 
TXDO and RXDO leads. As is well 
known, the MAX232 can handle more 
than just two lines - in fact, it can han- 
dle four. That’s why jumpers JP9 and 
JP10 and a second serial interface con- 
nector (K3) are on the board. You can 
also select either RS232 or USB for the 
UARTO interface. 

Now for a few words about the micro- 
controller ports. The microcontroller 
leads are routed to single-row socket 
headers in order to leave all options 
open. However, specific functions have 
also been assigned to most of the port 
leads. Here 8-bit port P0 is intended to 
be used for connecting the LCD mod- 
ule, but it can of course be used for 
some other purposes if you don’t need 
an LCD. A standard alphanumeric LCD 
can be driven in 4-bit mode using only 
six port pins. Leads P0_2 to P0_7 are 
thus used by the LCD. 

P0_0 is reserved for the debug inter- 
face (TXD1) and is only available for 
user applications if the debug function 
is not used. That still leaves P0_1. As 
this lead can also be used as an ana- 
logue input, a potentiometer providing 
a variable input voltage of 0-5 V can 
be connected to it via JP 13. A supple- 
mentary protective resistor (R17) pre- 
vents overloading if P0_1 is acciden- 
tally configured as an output while 
connected to the potentiometer. The 
two jumper pins can also be used as a 
measurement input. If you want to 
connect a sensor that outputs both 
positive and negative voltages, you 
can use the potentiometer to adjust 
the zero point to where you need it. 
The four lower bits of Port 1 can be 
connected to the four LEDs via 
jumpers and series resistors. That’s 
ideal for your initial programming exer- 
cises, such as those described in the 
February issue. If you haven’t already 
tried the ‘blinker’ example program, 
now’s your chance to get up to speed. 


If you remove jumpers JP3-JP6, these 
leads can also be used as four addi- 
tional analogue inputs. Just add a few 
lines of code, and you have a four- 
channel digital multimeter with LCD 
display! 

A total of seven individual port leads 
have been left open, but you’re bound 
to think of a use for them. Applica- 
tions such as an I_C or SPI interface 
and the like can always use an extra 
lead or two. 

It takes a bit of juice 

There are two options for powering the 
board, which are selected using JP11. 
Either you can use the power supply 
connector (Kl) and voltage regulator 
IC21, or you can use USB with its built- 
in 5 V supply voltage. 

If you’re using USB anyhow, it makes 
sense to dispense with an external 
power supply. However, a bit of cau- 
tion is advisable here. According to the 
USB specification, every USB down 
port is supposed to be protected 
against overloads by a PolySwitch pro- 
tective device. However, painful expe- 
rience proves that it just ain’t so. A 
simple short on the USB supply line 
results in a small puff of smoke from 
the PC motherboard and causes the 
corresponding down port to be perma- 
nently disconnected from the supply 
voltage. For cost reasons, manufactur- 
ers obviously do nothing more than 
placing small series resistors in the 
supply tracks, which then simply melt 
through. 

For this reason, a PolySwitch protective 
device (FI) rated at 100 mA is included 
on the application board for the spe- 
cific purpose of protecting the PC. That 
creates peace of mind and allows you 
to experiment in a relaxed mood. 

USB interface 

Next we come to the USB interface. 
The PL2303X, which sports the desig- 
nation ‘USB to Serial RS232 Bridge 
Controller’, comes from the Taiwanese 
manufacturer Prolific (sales rep: Glyn). 
Attentive readers may recall having 
already seen this Prolific IC in a built- 
in, encapsulated form in an interface 
converter cable described in the Sep- 
tember 2005 issue of Elektor Electron- 
ics. 

This IC is a full-speed USB device for 
USB 1.1 and thus compatible with the 
more recent USB 2.0 interface. That 
means the data transmission rate on 
the bus is 12 Mbit/s. R5 connects the 


40 


elektor electronics - 3/2006 



D+ lead of the USB connector to 3.3 V 
to signal a full-speed device to the PC. 
That causes the PC to load a driver for 
a virtual serial interface. Such a driver 
allows serial interfaces to be operated 
at transmission rates up to 1,228,800 
baud (that’s 1.2 Mbaud!). In line with 
the capabilities of the R8C/13, various 
standard baud rates are used here. The 
virtual serial interface behaves exactly 
the same as a real RS232 interface for 
downloading and debugging programs. 
Figure 2 shows the internal structure 
of the IC, which consists of a USB 
transceiver, a serial interface, and two 
data buffers. The data buffers support 
fast, uninterrupted data transfers, with 
data blocks being packed into individ- 
ual USB frames. It is also possible to 
connect an I_C EEPROM to store user 
configuration settings, but that option 
isn’t used here. 

The non-inverted RXD and TXD signals 
are available at the serial side of the 
converter and can be connected directly 
to the R8C. The inputs of the PL2302X 
are compatible with 3.3-V and 5-V logic 
levels. The TXD, DTR and RTS outputs 
provide either 3.3-V or 5-V logic levels, 
depending on the voltage connected to 
pin 4. In this case, this voltage is 3.3 V 
from the internal voltage regulator of 
the PL2303. That means the level 
applied to the serial input of the R8C/13 
is 3.3 V, although the level actually 
expected there is 5 V. That’s permissi- 
ble, though, because the R8C/13 can 
also be operated at 3.3 V, and besides 
that a 3.3-V signal at the RXD input of 
the microcontroller is adequate even 
when it’s operated at 5 V. All inputs of 
the R8C regard any voltage above 
0.2 V cc as a logic ‘high’ level. 

Driver installation 

You may have already used a Prolific 
USB adapter with your system. In that 
case, the interface will be recognised 
as soon as the board is connected to 
the PC. If it isn’t, or if you experience 
problems using the USB port, you 
should install the latest version of the 
driver. You can obtain the driver by 
downloading the file 050179-3-ll.zip 
from the Elektor Electronics website 
( www.elektor-electronics.co.uk ). It con- 
tains the file ‘PL-2303 Driver 
Installer.exe’. 

Run the driver installer file before con- 
necting the board. Any older version of 
the driver present in the PC will be 
deleted automatically when the new 
driver is installed. The next time the 
board is connected (or another inter- 



Figure 4. Configuring the buffer sizes and COM port number. 


face converter using the Prolific IC is 
connected), Windows will automati- 
cally locate the appropriate driver and 
load it. After that, your PC will have an 
additional serial interface that can be 
used just like a normal RS232 interface. 
If you have already installed several 
such interface converters, Windows 
will assign a high COM number to the 
new virtual interface. In that case, it’s 
recommended to use Advanced Set- 
tings to rename the interface, for exam- 
ple to ‘COM2’. You can usually ignore 
any message saying that this interface 
is already in use, because it refers to 
another virtual interface that is not 
used at the same time. All you need to 
know is which serial interfaces are 
actually present in your PC in hard- 


ware form. For example, the PC used 
for our tests had only COM1 present on 
the motherboard, but it also had an 
interface card with COM3 and COM4. 
In that case it’s a good idea to name 
the virtual interface ‘COM2’ (see Fig- 
ure 3), especially since many older pro- 
grams only support COM1 and COM2. 
Problems with high COM numbers 
have also been observed with the FDT 
download program, so you should at 
least keep the number in the single- 
digit range. 

In some cases it may be necessary to 
configure the FIFO buffer of the virtual 
interface to the smallest possible size 
(Figure 4) in order to obtain reliable 
communication. That’s because with a 
large buffer size, it’s theoretically pos- 


! COMPONENTS 
| LIST 

Resistors: 

R1-R4,R7= lkD 
R5 = 1 kfl5 
1 R6 = 47kD 

■ R8,R9,R10 = 4kD7 
I R1 1 = 33kD 

I R12 / R13 / R14 = 220kD 
| R1 5,R1 6 = 27D 
I R17= lOkfl 
I PI ,P2 = lOkD 

Capacitors: 

C 1 -04,08,0 1 1 ,C 1 2,C 18 = lOOnF 
05,06 = lOpF 

07,09,013 = 1 OjLtF 16V radial 

■ CIO = 220|iF 25V 

I C 1 4-C 1 7 = 4|iF7 25V radial 

I Semiconductors: 

| D1-D4,D6 = LED 
l D5 = 1 N4002 


D7 = 1N4148 

IC1 = PL2303X (Prolific) 

IC2 = 7805 
IC3 = MAX232 

Miscellaneous: 

JP3-JP6JP1 2 = jumper 
JP7-JP1 1 = 3-way SIL pinheader 
K1 = 2-way PCB terminal block, lead 
pitch 5mm 

K2 = USB socket, type B for PCB 
mounting 

K3,K4 = 9-way sub-D socket, angled 
pins, PCB mount 
K5-K8 = 16-way SIL pinheader 
K9 = LCD module, 2x16 characters 
SI = pushbutton with 1 make contact 
(e.g. TS695) 

FI = 100 mA Polyfuse 
X2 = 1 2MHz quartz crystal 
PCB, bare, order code 050179-1 
PCB, ready-assembled and tested, order 
code 050179-92 
LCD with backlight, order code 
030451-72 

Poly-LED display, order code 
030451-73 


3/2006 - elektor electronics 


41 





HANDS-ON 


MICROCONTROLLERS 



Figure 5a. The track and ... 


42 


elektor electronics - 3/2006 













o o o o o o o o 
^/o (b c o 


P1.0 

OO I Analog 


050179-1 


COM port 


programming 


Power LED 


Contrast LCD 



TxDI 



PO.1 



P0.2 



P0.3 

mod 



P0.4 



P0.5 

P0.6 

P0.7 



IVcc 

P3.0 

AVss 

P3.1 



AVcc 



P3.2 



P3.3 





7 




7 


Figure 5b. ... component layouts of the double-sided circuit board. 



Figure 6. The fully assembled prototype board. The component overlay is slightly different from the production version shown in Figure 5. 


3/2006 - elektor electronics 


43 












































HANDS-ON 


MICROCONTROLLERS 


sible for the PC software to be 
waiting for reply while the 
query is still stuck in the buffer. 

If errors occur when download- 
ing programs into the flash 
memory of the microcontroller, 
reducing the size of the buffer may 
improve the situation. 


Board assembly 

The printed circuit board (Figure 5) is 
also available fully assembled so 

readers with relatively little soldering 
experience don’t have to worry about 
problems with the Prolific IC (IC1), 
which is only available in a 28-lead 
SMD package (SSOP-28). If you assem- 
ble the circuit board yourself, you 
should start with this IC because it’s 
easier to solder if the board is other- 
wise empty. 

Numerous Elektor Electronics SMD 
projects have shown that they can be 
soldered without using special SMD 
tools. Start by soldering two diagonally 
opposite leads in place, after first care- 
fully positioning the IC. A check with 
a loupe will show whether you have a 
steady hand. If necessary, you can still 
adjust the position relatively easily at 
this stage. Continue by soldering an 
entire row of leads with a sufficient 
amount of solder. Any excess solder 
can be easily removed afterwards with 
a length of solder wick. If your final 
inspection with a loupe does not reveal 
any solder bridges, everything is OK. 
The author has also found that strong 
reading glasses (3 dioptre) are an 
excellent alternative to a loupe. 
They’re almost as good as stereo 
microscope, at only a fraction of the 
price. 

The remaining components shouldn’t 
present any special difficulties. You 
can omit the pin headers (K5 and K8) if 
desired. If you wish, you can later con- 
nect flat cable here or wire only the 
connections you actually need to the 
prototyping area. A socket header has 
proven to work well as an LCD connec- 
tor. The matching LCD module can 
then be fitted with long pin headers 
and simply plugged into the board. 


Initial test 

Before using the board for the first 
time, you should re-inspect the compo- 
nent assembly and solder joints and fit 
the necessary jumpers. The following 
jumper settings are important: 




JP 11: 

toward K7/K8 
(‘ext’ position, 
with power coming 
from an external supply) 

JP 3-6: fitted (LEDs 
connected) 

JP 12: fitted (‘Power’ LED 
connected) 

JP 2: fitted (debug mode) 

JP 7-10: toward IC3 (both interfaces 
via RS232) 

You should check the supply voltage on 
the board before plugging in the 
R8C/13 daughterboard, in order to 
avoid any risk to the microcontroller. 
LED D6 should light up after you con- 
nect an AC adapter with 9-V DC out- 
put. The voltage measured on I<6 
between pin 5 V ss (Pin 5) and pin 7 
(V cc ) must have a value of +5 V. After 
verifying this, disconnect the AC 
adapter and plug in the daughter board 
while no power is applied to the board. 
Now comes the most exciting moment! 
Reconnect the 9-V AC adapter. The 
‘Power’ LED will light up. Connect I<4 
to the COM1 serial port of the PC. You 
can immediately download a program 
now, because JP2 is configured for 
debug mode. Use the FDT program as 
described in the February 2006 issue of 
Elektor Electronics. A good choice for 
your first download is the ‘port_toggle’ 
program. The programming tool will 
indicate whether the download 
process completed successfully. 

Next, remove jumper JP2 and briefly 
press the Reset button. The four LEDs 
connected to Port PI should start 
blinking. 

If you want to use the USB interface, fit 
JP7 and JP8 in the proper positions 
(toward the USB connector). That will 
connect RXD1 and TXD1 to the USB 
converter IC. After that, you must con- 
figure FDT to use the virtual COM 
interface. Everything else works 
exactly the same as with a real RS232 
interface. 


KD30 debugger 

Up to now, we’ve only described how 
to download finished programs into 
the microcontroller and run them. 
When you’re developing a program, 
especially one that’s relatively com- 
plex, it’s helpful to use a debugger. 
That allows you to interrupt the pro- 
gram at any desired location, view 
memory contents, execute single 
steps, and much more. 

The microcontroller must always be in 
debug mode when you use the debug- 
ger, which means that jumper JP2 
must remain fitted. The Reset button 
isn’t necessary in this case, because 
you can only use software commands 
from the debugger to start and stop 
your program. 

We’ve prepared an extensive descrip- 
tion of how to get started with the 
debugger and placed it on the Elektor 
Electronics website at www.elektor- 
electronics.co.uk. Deeopnding on the 
amount of feedback we get, a special 
R8C activity page may also be created, 
so check out the website. 

( 050179 - 3 ) 

References: 

www.glyn.com 

www.glyn.de 

E-mail: elektor-r8c@glyn.de 

R8C forum: 

For hints and tips about using the 
R8C/1 3 board, check out the 'R8C 1 6- 
bit Micro Starter Kit' topic in our Forum 
menu at www.elektor-electronics.co.uk. 
Naturally, we would be pleased if you 
post your own tips and tricks on this 
forum for the benefit of other readers. 


44 


elektor electronics - 3/2006 





rl o1 Number One Systems 


Pocn. ^3 

for 

CaSy"rv 

Windows 


The world beating PCB design software 




A. 

'.J- Tfc 

-.iV 1 * 

y ** • 

Hi 1 " 

>*■, Ml 

' w ■ 

1 ' ■ 

■ 1 _ ^ ■ >, “ ‘ 

s’ 1 '-, 5 ' ' 

i* l,L 

I* 1 t 

L '' r’TL ■ -r"" ^ 

■ b 8 ' 

V \ 







Easy-PC version 9 just gets better 

Winning accolades the world over, Easy-PC for Windows V9 
is another major milestone in the evolution of this extremely 
popular software tool. Try a demonstration copy of Easy-PC 
and prepare to be amazed at the power, versatility and 
remarkable value for money. 





If 


7+1 


Version 9 fetaures 



■ 3D Board View 

■ New Win XP User Interface 

■ Reverse Engineer SCM from PCB 

■ Track Fattening 

0 Interactive Schematic Routing 
H New Sliding Toolbars 

■ Component Clearance Checks 

■ Alphanumeric Pin Names 

Plus many more exciting features 


.Ul ■ 


Fully integrated Schematics & PCB layout in a single 
application complete with forward and back annotation. 
Design and rules checks at all stages ensure integrity at 
all times. Professional manufacturing outputs allow you 
to finish the design process with ease. 


Stop press... Stop press... Stop press... Stop press... 

Easy-PC imports Eagle files as well asTsien Boardmaker 2 files 

call for a brochure, prices & CD on +44 (0)1684 773662 
or e-mail sales@numberone.com 
you can also download a demo from 

www.numberone.com 

Number One Systems - Oak Lane - Bredon - Tewkesbury - Glos - United Kingdom - GL20 7LR UK 



ss 

Designed for 


Microsoft® 

Windows®XP, 
2000, ME, 98, 
Windows NT® 




DON'T LOSE YOUR TEMPEf 


Before phoning us - if you are looking 
for a hard-to-find part. We have over 
20,000 items in stock - including obsolete 
and up-to-date parts. 

WHY NOT VISIT OUR WEBSITE 
www.crickIewoodelectronics.com 


2N 2SA 2SB 2SC 2SD 2P 2SJ 2SK 3N 3SK 4N 6N 17 40 AD 
ADC AN AM AY BA BC BD BDT BDV BDW BDX BF 
BFR BFS BFT BFX BFY BLY BLX BS BR BRX BRYBS 
BSS BSV BSW BSX BT BTABTB BRWBU BUK BUT BUV 
BUW BUX BUY BUZ CA CD CX CXA DAC DG DM DS 
DTA DTC GL GM HA HCF HD HEF ICL ICM IRF J KA 
KIAL LA LB LC LD LF LM M M5M MA MAB MAX MB 
MC MDAJ MJE MJF MM MN MPS MPSA MPSH MPSU 
MRF NJM NE OM OP PA PAL PIC PN RC S SAA SAB 
SAD SAJ SAS SDA SG SI SL SN SO STA STK STR STRD 
STRM STRS SV1 T TA TAA TAG TBA TC TCA TDA TDB 
TEA TIC TIP TIPL TEA TL TLC TMP TMS TPU U UA 
UAA UC UDN ULN UM UPA UPC UPD VNXXRZZN 


ZTX + many others 


We accept Mail, telephone & email orders. 
Callers welcome. 

Opening hours Mon-Sat 9:30 - 6:00 







VISA 


Connect 

L J 


Cricklewood Electronics Ltd 

40-42 Cricklewood Broadway London NW2 3ET 
Tel: 020 8452 0161 Fax: 020 8208 1441 
sales @ cricklewoodelectronics.com 


3/2006 - elektor electronics 


45 





HANDS-ON 


MODDING & TWEAKING 


Cheap Logger 

Use a web router to read the 
gas/water/electricity meters 

Jeroen Domburg & Thijs Beckers 


This month we'll turn an inexpensive router into a data logger. This is provided with sensors 
that monitor the readings on gas, water and electricity meters. One of the benefits of using a 
router is that the logger can be connected directly to an internal computer network and can 
therefore be accessed from any PC with an Internet browser. 




every five minutes, making it possible 
to create nice graphs from the data. In 
this way you can find out during which 
part of the day the consumption is 
highest, which can lead to better use 
of the resources and smaller utility 
bills. 

The device itself can be permanently 
fixed close to the meters. All measure- 
ments can be accessed via the built-in 
web server, programmed specifically 
for this task. The meter reader can 
therefore be hooked up to the home 
network and accessed from any com- 
puter. 

The router used is again the ‘Sweex 
broadband router’ with four 100 MBit 
ports, type number LB000021 (without 
WLAN). The reason we’ve chosen this 
router is that it is still one of the cheap- 
est available (£ 17.50 from scan.com). 
The rest of the hardware isn’t pricey 
either: the costliest are the microcon- 
troller (an ATTiny2313 made by Atmel, 


The Sweex LB000021 is still one of the cheapest routers that can run 
Linux. At the time of writing, this model was available on the Internet for 
less than £20, including postage costs. 

When we look inside this router we see a pair of unpopulated headers on 
the board. The smaller of the two (circled in red) is the serial port, which 
well use for this project. 

This is the board with the microcontroller, which well hook up to the port. 
The circuit is so simple that it can easily be built on a piece of 
experimenter's board. 


In last month’s article 
we described an inex- 
pensive router and 
showed how it could 
be reprogrammed with 
our own firmware. 
This month we’ll use 
the same router, with 
some additional elec- 
tronics, and build a 
gas, water and elec- 
tricity consumption 
meter. 

This meter 
has four sen- 
sor inputs 
and can 
therefore 
read a maxi- 
mum of four 
meters. The 
consumption 
is read out 
and stored 


46 


elektor electronics - 3/2006 








The board is connected to the serial port and fixed to the router PCB using a folded piece 
of duct tape. There is no need to use expensive screws or other fasteners. 

A multitool is ideal for making the hole in the case for the sensor cables. A cable-tie 
around the cables functions as a strain relief. 

The router is connected, ready for the firmware update. The network cable connects 
directly to a PC. This UTP cable may be either a crossover cable or a 1:1 cable. 






tu_ 


R1 


U b 0 

TxD 0 - 
RxD 0 - 
GND 0 


D1 


D2 


D3 


11 


100|i 


20 


© 


RESET 

PB7 


PB6 

PDO |C1 

PB5 

PD1 

PB4 

PD2 

PB3 

PD3 

PB2 

PD4 

PB1 

PD5 

PBO 

PD6 


ATTiny2313 


o 

X 

XI 


D4 





which should be available for a few 
pounds) and the sensors. 

This project consists of three parts: the 
router itself, which acts as web server 
and stores the data, the board with the 
microcontroller, and the sensors. The 
router communicates with the micro- 
controller every five minutes. The lat- 
ter uses sensors to keep track of the 
meters. 

The sensors are optical and the types 
used depend on the meter they have to 
read. The general idea is that the sen- 
sor ‘looks’ at the gas, water or electric- 
ity meter. 

Most modern electricity meters have 
an LED, which flashes every time a 
certain amount of power has been con- 
sumed. This pulse can of course be 
easily detected by a simple LDR. Older 
meters have a rotating disc with black 


XI = 20MHz 


Figure 1 . The microcontroller circuit is fairly simple and can easily be built on a piece of 

experimenter's board (see inset). 


Once everything is connected, the router can be found 
at IP address 192.168.2.1. The firmware can be 
upgraded to the GWE-meter firmware by selecting 
'firmware upgrade' from the 'tools' menu. 

It works! With the firmware upgraded, the router 
can be connected to the network. The ex-router will 
be given an IP address automatically. Take a look at 
the configuration of your gateway, router or 
cable/ADSL modem to find out what the address is. 



3/2006 - elektor electronics 


47 








HANDS-ON 


MODDING & TWEAKING 


The time has come to connect the sensors. A modern 
electricity meter with a flashing LED is the easiest... 
An LDR covered by a piece of duct tape is sufficient to 

obtain an accurate reading. 



markers. These meters can be read 
with the help of reflective optical sen- 
sors such as the CNY70, or the OPB704 
(more expensive, but better). 

Gas and water meters usually have a 
mark on one of the least significant 
digits (often the ‘0’ or ‘6’). A reflective 
sensor can be used without too many 
problems in these cases as well. 
Whichever type of method is used for 
the measurements, all sensors occa- 
sionally exhibit a drop in their resist- 
ance. The capacitors connected to the 
sensors (see Figure 1) and some clever 
firmware in the microcontroller enable 
these resistance changes to be read. 
The firmware keeps track of the num- 
ber of times that the current drops 
below a certain value and hence how 
often a change of resistance has 
occurred. This count gives a good indi- 
cation of the consumption over a given 
time. The counters can be read or reset 
via the serial port of the microcon- 
troller. The calibration of the sensors 
also takes place via this route. 

The microcontroller’s serial port is con- 
nected to a header in the router (JP2). 
This header normally isn’t mounted on 
the board. The serial port of the router 
ends up at this header (see Figure 2). 
The router itself runs a dedicated ver- 


sion of the firmware. The firmware 
contains a program that takes care of 
the communications with the micro- 
controller and makes sure that the 
counters are read at the right time. As 
we mentioned earlier, this occurs every 
five minutes. The data are stored in the 
internal RAM of the router. This has 
the advantage that about a year’s 
worth of data can be stored; the disad- 
vantage is that all this data will be lost 
if there is a power cut. Luckily, this can 
easily be prevented by the inclusion of 
a back-up battery in the power supply; 
this will be covered in detail later on. 
The firmware inside the router con- 
tains a simple web server and several 
server-side scripts; these enable every- 
thing, including the network settings 
and sensor calibrations, to be accessed 
via a browser. It is also possible to use 
the browser to view the data in differ- 
ent formats. The data of one or more 
selected sensors can be viewed as a 
graph. Alternatively, the raw data can 
be downloaded as a CSV file, for use in 
Excel. 

The facility to update the firmware 
hasn’t been forgotten either. Using this 
update facility, the official Sweex 
firmware can be flashed back into the 
router, so it can be used again as a nor- 


mal router. It’s worth noting that the 
meter firmware hasn’t stopped the 
internal switch from working: the four 
LAN ports and the WAN port are con- 
figured as a single switch by this 
firmware. 

So far so good, but how can you obtain 
this firmware? The answer is very sim- 
ple: the required firmware is available 
from both the Elektor website [1] (file 
number 050360-11. zip), and the 
author’s own site [2]. The Linux kernel 
and all other tools used are licensed 
under the GPL (General Public 
License), which means that the source 
code of the programs has to be made 
available along with the firmware. The 
author has of course complied with 
this requirement. He has also made the 
tools available that were written 
specifically for use with the meter 
firmware. These can also be down- 
loaded from the above-mentioned 
sites. 

Installing the firmware is fairly simple: 
the router already has a facility to 
upload a firmware upgrade and this 
method can also be used to smuggle 
our firmware into the router; refer to 
the inset for more info. If you want to 
flash the original firmware back into 
the router, you can use the method 



The circle of the '6' in this gas meter is not filled 
in, which can be detected by a reflective optical 
sensor. 

The reflective sensor is fixed to the meter using a 
bit of Blu Tack. 


48 


elektor electronics - 3/2006 





This water meter is a lot more difficult to read: there are no 
distinguishable digits, no flashing LEDs... 

In principle it should be possible to use a reflective sensor to 
detect a dial, possibly using a blue LED. However, this has 
not been extensively tested by the author. 


described earlier. 

The microcontroller can be pro- 
grammed via the parallel port of a PC 
and a programmer [3], consisting of a 
DB25 connector and three resistors. 
The required programming software is 
available for Windows as well as other 
operating systems. 

The physical placement of the sensors 
depends very much on the type of 
meter they’re used with. A meter with 
a flashing LED is easiest: an LDR can 
be stuck with tape over the LED. A gas 
or water meter can be trickier, but as 
long as the reflective sensor can point 


JP2 

4m 

1: RxD 
2: +3V3 
7: TxD 
8: GND 


Figure 2. These ore the connections 
of JP2 in the router. 


+U, N D1 +Ub 



© | © 

050360 - 2 - 17 


Figure 3. The back-up supply is inserted into the 
supply line. This diagram shows that it is a fairly 
simple circuit. 


straight onto the last digit, it shouldn’t 
cause too many problems either. The 
author couldn’t test an electricity 
meter without an LED (i.e. , one with 
just a rotating disc), but it is likely that 
the black marker on the disc can be 
detected by a reflective sensor after a 
bit of experimentation. 

Once the sensors have been fixed into 
place and connected to the microcon- 
troller, they have to be calibrated. 
There is a link on the web page of the 
router that helps with this. This func- 
tion continuously reads the (analogue) 
value of the sensor until the user has 
determined that the calibration is com- 
plete. The minimum and maximum sig- 
nal levels are extracted from these 
readings. Each time that a sensor’s 
output changes by more than two- 
thirds of the difference between mini- 
mum and maximum, the microcon- 
troller assumes that another unit of 
gas, water or electricity has been used. 
There is no need to worry that the 
router itself will significantly increase 
your electricity bill: it only draws about 
340 mA from its 12 V supply. The 
power consumption is therefore about 
5 watts. The router itself contains a 
switch-mode PSU; any voltage from 6 
to 15 Volts was found to be suitable. 
Armed with this information, we can 
design a simple back-up circuit to keep 
the data safe during a power cut. A 9 V 
NiMH or NiCd battery can keep the 
router powered for some 20 minutes. 
Six beefy NiMH cells give a back-up 
time of about three hours. During this 
period the meter continues to take 
readings. The measurements of all con- 
nected meters are therefore preserved. 
The circuit in Figure 3 shows how a 
back-up supply should be connected. 
This circuit should be inserted 
between the adapter and the router. 
The two diodes ensure that no current 
can flow from the adapter to the bat- 
tery and vice versa. The resistor pro- 
vides enough current to the battery to 
keep it fully charged during normal 


Web links 

[1] www.elektor-electronics.co.uk/, 
items March 2006. 

[2] http://sprite.student.utwente.nl/ 
~jeroen/ projects/ gwemeter 

[3] http://sprite.student.utwente.nl/ 
~jeroen/ projects/ progavr 


use. If you use Schottky diodes the 
voltage drop, and hence the losses, are 
kept to a minimum. The value for the 
resistor is calculated as follows: 

R = 

(LT b - C7 batt ) / (0.02 x battery capacity) 

For example, when a 12-V adapter and 
9-V battery with a capacity of 800 mAh 
are used, the resistor should take a 
value of about 180 Q. 

( 050360 - 2 ) 


About the 
author: 

Jeroen Domburg is currently 
studying electronic engineering 
at the Saxion University in 
Enschede (The Netherlands). He 
is an enthusiastic hobbyist, 
who spends much of his spare 
time on microcontrollers, 
electronics and computers. In 
this section we will be able to 
examine and build some of his 
projects. 


3/2006 - elektor electronics 


49 






Karel Wa I raven 

Recharging batteries for devices such as digital cameras can be a problem when you're on 
holiday in a remote or inhospitable region. You won't find an electrical outlet anywhere. 
Naturally, you can count on an Elektor Electronics designer to whip up a solution using a solar 
panel and a DIY Li-ion battery charger. 


I was due a bit of a holiday, so I sug- 
gested to management that I’d step 
out for half a year. Their response was 
less than enthusiastic, and my own 
enthusiasm was soon dampened when 
I had a good look at what it would 
cost. The outcome was thus four 
weeks of trekking through the Anna- 
purna region in Nepal. 

To meet my electrical energy needs, I 
took along a solar panel and a simple 
Li-ion charger built from discrete com- 
ponents. I didn’t have a lot of time, and 
in the spirit of the motto ‘better a good 
copy than a bad design’, I cribbed the 
accompanying circuit from a well- 
known Chinese company. 

As you doubtless know, charging 
lithium cells is actually quite easy. You 
generate a well-regulated voltage of 


exactly 4.1 or 4.2 V (always read the 
manufacturer’s specifications to deter- 
mine the right value) and add current 
limiting to keep the current within 
bounds. The charging current will 
automatically decrease as the cell 
becomes charged (see Figure 1 for the 
charging characteristic). 

You can assume that the cell is fully 
charged when the charging current 
drops to 1/20C or less. Just to reiterate, 
the charging voltage is critical - the 
allowed tolerance is only 1%. That’s 
not very much, because 1% of 4.2 V is 
only 42 mV. That means you have to 
measure the output voltage carefully to 
ensure that it stays within tolerance. 
The nice thing about this circuit (Fig- 
ure 2) is that it’s easy to build as a DIY 
project because it doesn’t use any 


obscure components. The TL431 volt- 
age reference is an old standby that 
you can obtain almost everywhere. For 
the rest, it consists of a few ordinary 
transistors and a power transistor, all 
of which can be replaced by any rea- 
sonable equivalents. The Schottky 
diode can be any type that can handle 
1 A, or if necessary you can use an 
ordinary 1N4001. The input voltage 
can also be higher, although beyond a 
certain point you’ll have to fit a heat 
sink for Tl. 

Design philosophy 

It’s always interesting to examine 
someone else’s design carefully in 
order to figure out the underlying 
design philosophy. 


50 


elektor electronics - 3/2006 







Reference voltage 

To start with, the circuit is based on a 
good, stable reference voltage gener- 
ated by a Texas Instruments TL431 
(IC2). That’s a prudent choice, 
because a good reference is a funda- 
mental requirement if you want to be 
sure of achieving 1% accuracy for the 
charging voltage. 

The reference IC is followed by an 
emitter follower (T4) so the reference 
source can supply more than just a few 
milliamperes. That would normally 
reduce the output voltage by approxi- 
mately 0.6 V and trash the stability, but 
feedback from the transistor via R21 
and R23 eliminates those problems. 
The IC adjusts its reference potential 
to maintain a voltage of 2.5 V on its 
Adjust input. That yields a reference 
voltage of 3.3 V, which is used every- 
where in the circuit. It’s important to 
be able to adjust the value of R21 or 
R23 when you’re building charger if 
the voltage of the TL431 differs too 
much from the nominal value. If a 
check reveals that your reference IC is 
near the end of the tolerance range, 
correct the reference voltage by fitting 
a resistor in parallel with R21 or R23. 
You can simply use the trial-and-error 
method by trying a succession of val- 
ues until you obtain the correct volt- 
age. Once that’s done, you can solder 
the resistor permanently in place. 

Naturally, a reference voltage of 3.3 V 
represents an arbitrary choice. It could 
also be a bit higher or a bit lower. It 
shouldn’t be all too high, though, to 
avoid restricting the headroom of the 
TL431. A more important consideration 
is that the reference voltage must fall 
within the common-mode input volt- 
age range of the opamp used in the cir- 
cuit. We’ll say more about that when 
we talk about selecting the opamp. 

A decidedly low reference voltage, 
such as 2.5 V (as obtained without a 
voltage divider), is also undesirable 
because it makes it more difficult to 
drive LED D1 and increases the sensi- 
tivity of the circuit to the input offset 
voltage of the opamp. 

Control circuitry 

Now we come to the actual control cir- 
cuitry. We want to have: 

• a stable output voltage 

• current limiting 

• battery monitoring (for temperature) 

• a clear indication when the battery 
is fully charged 



Figure 1. Charging characteristic of an Li-ion cell (source: Panasonic). 



Figure 2. The circuit of the charger uses standard components instead of special charger ICs. 


3/2006 - elektor electronics 


51 


TECHNOLOGY 


LABTALK 





Figure 3. The small printed circuit board for the charging circuit. 
The spring contacts for the battery pack are at the right. 


The first three items all affect the out- 
put voltage. The output current can be 
reduced by lowering the output volt- 
age, and if the battery becomes hot, 
the charging current must be reduced 
by lowering the output voltage. 

Here we have a topology in which 
three opamps (IClb, IClc and ICld) 
can simultaneously control a single 
output. That’s possible using a sort of 
OR-gate arrangement. In the 
schematic diagram, you can see that 
the outputs are simply connected 
together. Under normal conditions, 
that would naturally lead to problems 
whenever one opamp tries to increase 
the output voltage while another one 
tries to reduce it. That problem can be 
solved by putting diodes or transistors 
after the opamps. 

In this case, a more elegant solution is 
to use opamps with open-collector out- 
puts. That means each opamp can only 
reduce the voltage on the shared out- 
put. Resistor R8 provides the pull-up 
voltage. It supplies the base current for 
T2, which in turn drives T1 into conduc- 
tion and voila, the positive terminal of 
the battery is connected to the positive 
supply voltage. This gives us a system in 
which each parameter (voltage, current, 
and temperature) has its own opamp 
that can reduce the output voltage. 

Current regulation 

As a rule of thumb, you can assume 
that the maximum charging current of 


a normal Li-ion battery is around 0.7 to 
1 times its capacity. This charger deliv- 
ers a maximum current of 0.65 A, 
which makes it suitable for batteries 
rated at 0.65 Ah or more. 

The current with a fully discharged 
battery would ordinarily be higher 
than the above-mentioned 0.65 A. The 
current can be easily measured by con- 
necting a small resistance in series. 
Here that role is fulfilled by R17 and 
R18, with two resistors being used due 
to the magnitude of the current and 
the power dissipation. The current 
generates a voltage across these resis- 
tors, and ICld compares this voltage 
with a reduced reference voltage 
obtained from a voltage divider. If the 
voltage generated by the charging cur- 
rent is higher than the comparison 
voltage, ICld takes control by reducing 
the voltage on the shared output. That 
lowers the charging voltage for the 
battery and thus reduces the charging 
current to the desired level. 

When the battery becomes fully 
charged, the control function provided 
by IClc prevents the voltage from ris- 
ing above 4.2 V. The battery voltage is 
compared with the reference voltage 
via two voltage dividers (R15/R16 and 
R7/R4, respectively), and if necessary 
IClc reduces the voltage on the 
shared output. 

The logic of the temperature monitoring 
circuitry with IClb is similar. A thermis- 
tor (NTC resistor) is built into the bat- 


tery, and its resistance decreases as the 
temperature increases. The thermistor 
forms a voltage divider in combination 
with Rl, and IClb compares the voltage 
at the junction of this divider with a 
reduced reference voltage obtained 
from divider R14/R3. It restricts the 
charging process if the temperature 
rises too high. 

By the way, this temperature protec- 
tion is not fail-safe, so charging will 
proceed as normal if there is bad con- 
tact or an open lead. 

If you’ve ever built a circuit with an 
opamp followed by two transistors 
(which also provide gain), you know 
you can expect problems. Such a cir- 
cuit is guaranteed to oscillate. That 
problem is solved here by using a hefty 
capacitance (Cl) to slow down the 
entire control loop. An additional 
capacitor (C2) connected at the output, 
in combination with voltage divider 
R15/R16, keeps the circuit stable in the 
no-load state, and the divider provides 
a minimum load. 

Indicator 

We haven’t said anything yet about the 
indicator portion of the circuit, which 
consists of the circuitry around ICla. 
This bit of electronics is not essential 
to the operation of the circuit, but it is 
nevertheless very important. As a user, 
you naturally want to know where 
things stand. The nice thing about this 
indicator is that it responds to the 
charging current. That means you can 
be sure that charging is actually taking 
place, which avoids simple errors such 
as forgetting to connect the mains 
adapter or a bad battery contact. 

Here again the reference voltage is 
divided down, this time by R12/R19, to 
a voltage of approximately 14 mV If the 
voltage drop resulting from the charg- 
ing current through R17/R18 is less 
than this value (with no battery con- 
nected or a fully charged battery), the 
internal open-collector output transis- 
tor of ICla will be cut off. The red LED 
in D1 will be off in that case, but the 
green one will be on because it is con- 
nected to 3.3 V and to ground via a 
220-fl resistor. 

In the opposite case, with sufficient 
charging current flowing, ICla will pull 
its output low. In that case LED will be 
on and T3 will conduct to short out the 
green LED and keep it dark. Using a 
bi-colour LED for D1 thus provides a 
perfectly clear charging indicator. 
Have you already realised the signifi- 
cance of selecting 14 mV as the refer- 


52 


elektor electronics - 3/2006 







ence voltage for ICla? The maximum 
charging current of 650 mA generates a 
voltage drop of 153 mV across 
R17/R18. 14 mV is approximately 1/11 
of this value, so the battery is consid- 
ered to be fully charged as soon as the 
current drops to 1/11 of the maximum 
value. The charging process will con- 
tinue as usual, but the LED will indi- 
cate that the battery is fully charged. 
You could also add another stage to 
the circuit, because it’s better to limit 
the charging current to 1/10 of the 
battery capacity if the battery has 
been discharged to below 2.9 V. That 
can be easily implemented by using 
another opamp to connect a resistor 
in parallel with R5 to reduce the 
divided reference voltage for current 
limiting to 14 mV. However, the man- 
ufacturer decided not to do this, pre- 
sumably because it would require an 
additional IC. 

Component selection 

Now for a few remarks about select- 
ing the opamp. When you design a 


circuit, you can choose from hundreds 
of IC types. All the different options 
don’t make the choice any easier. 
However, in this case a standard 
opamp type without any special prop- 
erties is sufficient. It doesn’t need to 
have especially high accuracy (a mil- 
livolt more or less doesn’t matter), it 
doesn’t have to have a special tem- 
perature range, and noise and speed 
are also unimportant. However, there 
are two aspects that deserve further 
attention. 

The first is the common-mode range. 
When you select an opamp for a cir- 
cuit, it’s important to keep all the volt- 
ages that may be present on its inputs 
within the limits of the common-mode 
range, or to select an opamp that can 
handle the expected range of voltages. 
The data sheet for the LM399 says that 
the lower limit is 0 V and the upper 
limit is 1.5 V below the supply voltage. 
If we had chosen an LM741, the lower 
limit would have been 1.5 V, so a volt- 
age such as 14 mV would not have 
been allowed. That means it’s essen- 


tial to chose an opamp for this design 
that can work properly with voltages 
close to zero. 

The second aspect is the offset volt- 
age. From the data sheet, you can see 
that the input offset voltage is 2 mV. 
(The manufacturer supplies this 
opamp in various versions with differ- 
ent offset voltage ratings. As you 
might expect, better specs always 
cost more.) That means the IC intro- 
duces an error of approximately 2 mV 
at its inputs. As a result, although you 
think (or hope) that the charging indi- 
cator will change state at 14 mV, it 
may actually change as early as 16 mV 
or not until 12 mV. That’s an error of 
more than 10%, which is considerable. 
That isn’t a problem for the charging 
indicator, but such an error in the 
charging voltage would be unaccept- 
able. That’s why the reference value 
for the charging voltage is much 
higher at around 2.4 V. An error of 
2 mV at 2325 mV is only around 1 part 
in a thousand, which is negligible. 

( 050396 - 1 ) 



CONSTRUCTIO 


Elektor Electronics (Publishing) does not provide parts and components 
other than pcbs, fornt panel foils and software on diskette or ic (not neces- 
sarily for all projects). Components are usually available form a number of 
retailers - see the adverts in the magazine. 


Large and small values of components are indicated by means of one of 
the following prefixes : 


E (exa) = 10 18 
P (peta) = 10 15 
T (tera) = 10 12 
G (giga) = 10 9 
M (mega) = 10 6 
k (kilo) = 10 3 
h (hecto) = 10 2 
da (deca) = 10 1 


a (atto) = 10~ 18 
f (femto) = 10“ 15 
p (pico) = 10“ 12 
n (nano) = 10“ 9 
H (micro) = 10“ 6 
m (milli) = 10“ 3 
c (centi) = 10“ 2 
d (deci) = 10 _1 


In some circuit diagrams, to avoid confusion, but contrary to iec and bs 
recommandations, the value of components is given by substituting the rel- 
evant prefix for the decimal point. For example, 

3k9 = 3.9 ka 4/x7 = 4.7 /xF 

Unless otherwise indicated, the tolerance of resistors is ±5% and their rat- 
ing is l A- l A watt. The working voltage of capacitors is > 50 V. 

In populating a pcb, always start with the smallest passive components, 
that is, wire bridges, resistors and small capacitors; and then ic sockets, 
relays, electrolytic and other large capacitors, and connectors. Vulnerable 
semiconductors and ics should be done last. 

Soldering. Use a 15-30 W soldering iron with a fine tip and tin with a resin 
| core (60/40) Insert the terminals of components in the board, bend them 
■ slightly, cut them short, and solder: wait 1-2 seconds for the tin to flow 
1 smoothly and remove the iron. Do not overheat, particularly when solder- 
ing ics and semiconductors. Unsoldering is best done with a suction iron 
or special unsoldering braid. 

1 Faultfinding. If the circuit does not work, carefully compare the populated 
] board with the published component layout and parts list. Are all the com- 


N GUIDELINES 



ponents in the correct position? Has correct polarity been observed? Have 
the powerlines been reversed? Are ah solder joints sound? Have any wire 
bridges been forgotten? 

If voltage levels have been given on the circuit diagram, do those meas- 
ured on the board match them - note that deviations up to ± 10% from the 
specified values are acceptable. 


Possible corrections to published projects are published from time to time 
in this magazine. Also, the readers letters column often contains useful 
comments/additions to the published projects. 


The value of a resistor is indicated by a colour code as follows. 



color 

1st digit 

2nd digit 

mult, factor 

tolerance 

black 


0 



brown 

1 

1 

xlO 1 

±1% 

red 

2 

2 

xlO 2 

±2% 

orange 

3 

3 

xlO 3 

- 

yellow 

4 

4 

xlO 4 

- 

green 

5 

5 

xlO 5 

±0,5% 

blue 

6 

6 

xl06 

- 

violet 

7 

7 

- 

- 

grey 

8 

8 

- 

- 

white 

9 

9 

- 

- 

gold 

- 

- 

xlO- 1 

±5% 

silver 

- 

- 

XlO- 2 

±10% 

none 

— 

— 

— 

±20% 


Examples: 

brown-red-brown-gold = 120 D, 5% 
yellow-violet-orange-gold = 47 kD, 5% 


3/2006 - elektor electronics 


53 



HANDS-ON 



Erik Martens 


What turns a mC board into a real PLC? A PLC is a controller with a program stored in memory, 
where reliability, availability and safety are of the utmost importance. Only when a mC board 
can be operated as a PLC and it complies with industrial standards can it be called a real PLC. 


This project covers all aspects to turn 
a standard AT89S8252 jliC board into a 
real PLC, using a minimum of off-the- 
shelf components. To add the PLC 
functionality to an AT89S8252 board 
we require a small section of extra soft- 
ware (firmware) in the microcontroller. 
Your own jliC PLC program then works 
under supervision of this firmware. 

System overview 

To turn a standard AT89S8252 board 
into a PLC we make use of four I/O 
pins on the microcontroller (P1.0 to 
PI. 3). When the controller is reset it 
knows from the state of the flip-flop 
(IC2a and IC2b, read via P1.0) whether 
a hardware reset or an internal reset 
occurred. After a hardware reset the 
firmware sets the flip-flop using Pl.l. 
Port Pl.l also turns off all output sec- 
tions (a high level from Pl.l turns off 
T1 via IC3d and IC2d). 

The STOP/RUN/RESET switch (SI) is 
used by the firmware to start and stop 
the PLC program. This switch can also 
be used (via R3) to force a hardware 
reset of the jliC. P1.2 is used to read the 
state of the STOP/RUN/RESET switch. 
When the switch is in the STOP posi- 
tion, all outputs are automatically 
turned off. LEDs D7 and D8 show the 
current status of the PLC program. 


Should the level of the supply voltage 
to voltage regulator IC4 drop below 
about 8.2 V, it will be reported to the 
jliC via P1.3, after which all output 
modules are immediately turned off. 

Two input modules have been 
included in the circuit diagram, but 
you can add as many as you need to 
ports PO, P2 or P3. The inputs are elec- 
trically isolated, can take +24V DC sig- 
nals, are protected against voltage 
spikes and polarity reversal. 

The output sections are also electri- 
cally isolated. You can connect as 
many output modules as you need to 
ports PO, P2 or P3. However, the output 
sections can only be active when T1 
conducts. This will only happen when 
all operating conditions are satisfied 
(Pl.l and PI. 2 high, STOP/RUN/RESET 
switch in the RUN position and a high 
enough supply voltage). 

To program the jliC you can use the 
SPI port (PI. 5, PI. 6 and PI. 7) on the 
jliC. The programming can only take 
place when the reset line is active. 
For this reason R8-R11 and IC3a have 
been added, so that a high RS232 
input (for example DTR) will keep the 
jliC reset line permanently high. The 
programming functionality via the 
SPI port is not shown in the circuit 
diagram. 


Firmware 

The main PLC program works under 
supervision of the so-called firmware. 
An example of this firmware has been 
included in this article and you will find 
it to be relatively small (about 100 
bytes). The jliC PLC firmware was writ- 
ten using the TASM shareware assem- 
bler. The use of this assembler has been 
covered in previous Elektor articles: 
‘89S8252 Flash Microcontroller Board’ 
(Dec. 2001), ‘Microcontroller Basics 
Course’ parts 1 and 2 (Jan./Feb. 2002). 
These articles also describe the differ- 
ent ways in which the microcontroller 
software can be put into the microcon- 
trollers (external programmer, SPI). 

The firmware takes care of the follow- 
ing functions: 

Reset 

After a reset the jliC will immediately 
start running the firmware. If a hard- 
ware reset occurred, the PLC will start 
the first PLC cycle if all other conditions 
are satisfied (STOP/RUN/RESET switch 
in the RUN position and a good supply 
voltage). When an internal reset occurs 
(when the cycle time was exceeded), 
the STOP/RUN/RESET switch first 
needs to be set to the STOP position, 
and then to the RUN position, before 
the PLC cycle will start again 


Please note: this project is has not been tested or post-engineered by the Elektor Electronics laboratory. 


54 


elektor electronics - 3/2006 



R3 


RS232: 
reset pC 


IC3.A 


0 


R9 


o 


27k 


R8 


JT 1 


RIO 
^ 1 8k2 


D9 


n 2 

1 4V7 


Js 


R11 


IC3.B 


JT 1 


I 


C5 


10p 

63V 


input module 

i-Qill— I 


+24V dc 


0 


ov 


4V7 


1 05K25 


10k 




JT 1 




1N4148 


SFH610-2 


input module 

H2k2 | — | SS ^ 


+24V dc 


0 


ov 


4V7 


1 05K25 


10k 


JT 1 




1N4148 


SFH610-2 


230V 


63mA T 


4x 1 N4001 


IC3.D 


IC3.C 


JT 1 


7T1 


IC2.A 


JT & 


IC2.B 


JT & 


SPI 


0 


x 




green 






green 


IC4 


Hahn 

EI4811172 



^6 

MOOn 


30_ 

29 


_ 10 _ 

_ 11 _ 

12_ 

13_ 

14_ 

15_ 

16_ 

17 


40 



© 


RESET 


EA/VP 

ALE/P 


PI .2 

PSEN 


PI .3 

P1.0 


PO.O 

P1.1 


P0.1 


IC1 

P0.2 



P0.3 

PI .4 


P0.4 

PI .5 


P0.5 

PI .6 


P0.6 

PI .7 


P0.7 

AT89S8252 

P3.0 


P2.0 

P3.1 


P2.1 

P3.2 


P2.2 

P3.3 


P2.3 

P3.4 


P2.4 

P3.5 


P2.5 

P3.6 


P2.6 

P3.7 


P2.7 

-1- 

XI 

X2 


20 

19 



X 

1 


H 

I- 

C7 






33p 

12MHz 





31 


IC3.F 


* 1TL 


39 

38 

37 

36 

35 

34 

33 

32 


21 

22 

23 

24 

25 

26 

27___ 
28 | 


Uj 

W 

Ui 

oc 

Q- 1 

SI 


IC2.C IC3.E 


18 




C8 

33p 


IC2 = 74HCT132 
IC3 = 74HCT14 


1N4148 


j? j§ 4 ^ C9 ' © C,o" (”) 

¥ IS? ¥ !“ 

63 V lOoiTf (7) 100n (7) 


(14) 

IC3 

© 


JT & 


JT 1 




Tr6 


green 


IC2.D 




RUN 


R4 




R7 


red 


D8 

r 

STOP 

R5 


I 


TIPI 25 


output module 


green 




-GO 


1N4001 


BC327 


- | 270 o | — 


© 


220k 


BD243C 


CNY17-3 

SFH601 


M 


output module 


tt 

>f 


green 




-GO 


1 N4001 


1N4001 


BC327 


1 1 270 Q | — 

I I 


© 

A 470k 


220k 


BD243C 


CNY17-3 

SFH601 


H 


1 N4001 


+24V dc 



+24V dc 



I 


030158-11 


Figure 1. Circuit diagram of a real PLC using an AT89S8252. 


RUN-STOP function 

The most important task of the 
firmware is to make sure that all con- 
ditions are satisfied before starting a 
PLC cycle. A PLC cycle can be started 
if the following conditions are met: 

• the STOP/RUN/RESET switch is in 
the RUN position; 

• the supply voltage is high enough; 

• the STOP/RUN/RESET has been 
switched from RUN-STOP-RUN after 
the PLC cycle time has been 
exceeded. 

STOP/RUN/RESET switch 

This switch is used to control the run- 
ning of the PLC program. When the 
switch is turned to the STOP position 
the currently running cycle is still com- 
pleted, after which no new PLC cycle 
is started. When the PLC is in the 


STOP condition all output modules are 
turned off. 

Supply voltage monitoring 

Before the start of every PLC cycle 
the firmware checks that the supply 
voltage is (still) in order. Should the 
supply voltage at the input of voltage 
regulator IC4 drop below about 8.2 V, 
a new PLC cycle will not begin and 
the ERRPS routine will be called 
instead. This routine can be used to 
store variables into a non-volatile 
memory (the EEPROM in the jaC) 
before the supply voltage drops too 
far for the jliC to stop functioning. If 
there is only a temporary drop in volt- 
age (caused by interference, for 
example), which doesn’t reset the jliC, 
the PLC cycle will start again as soon 
as the supply voltage is restored. 

PLC cycle-time watchdog 

You may know that the AT89S8252 


has an on-chip watchdog timer. This 
timer is used to keep an eye on the 
cycle time of the PLC program. At the 
start of every PLC cycle the watchdog 
timer is reset. Should a PLC cycle take 
too long, for example caused by an 
endless loop within the PLC program, 
the internal watchdog will generate 
an internal reset of the jliC . In the 
reset state of the jliC Pl.l will immedi- 
ately become ‘high’, which causes all 
output modules to be turned off. The 
firmware will then detect that an 
internal reset occurred (by the state of 
flip-flop IC2a/b) and will enter the 
STOP condition. Despite the fact that 
the STOP/RUN/RESET switch is in the 
RUN position, the PLC program will 
remain in the STOP condition. The 
program only exits from this condition 
when the STOP/RUN/RESET switch is 
turned to STOP. This behaviour pre- 
vents the PLC from starting again 
immediately after the PLC cycle time 


3/2006 - elektor electronics 


55 


HANDS-ON 



was exceeded. The maximum PLC 
cycle time can be set to one of the fol- 
lowing values: 16, 32, 64, 128, 256, 
512, 1024 or 2048 ms. 


Using the |iC PLC firmware 


Listing 1 

ORL WMCON, 0000 100 OB set EEMEN, select uC EEPROM 

MOV DPL, #010H 

MOV DPH,#000H 

MOVX A,@DPTR store contents of address 16 into the accumulator 


The PLC firmware included with this 


article should be used as the basis for 

r m as ™ 



your own PLC application. You only 

1 Listing 2 

■ 


need to add your code to the MAIN, 

■ 

1 

MOV 

DPL,#010H 

INIUC, INIPLC, ERRPS and ERRCY rou- 

■ 

1 

MOV 

DPH , #000H 

tines to provide the functionality you 

1 

ORL 

WMCON, #00010000B 

require. 

1 M001 

MOX 

A, WMCON 


I 

JNB 

ACC. 1,M001 

MAIN: This routine is called every 

I 

MOV 

A, B 

cycle. This is where the inputs are 

1 

1 

MOVX 

@DPTR, A 

read, the logical relationships are 

■ 

1 

ANL 

WMCON, #11101111B 


set EEMWE , write-enable uC EEPROM 
wait until the uC EEPROM is ready 


reset EEMWE , write-disable uC EEPROM 


calculated and the outputs are set. 
The MAIN routine may not run 
longer than the set watchdog time, 
so take care with delay loops and 
‘jumping back’. 

INIUC: When power is first applied to 
the jliC PLC this routine is called once. 
You could for example use this routine 
to restore variables from the EEPROM 
of the microcontroller. The example 
below shows how to get the contents 
of EEPROM address 16 and store it in 
the accumulator (see Listing 1). 

INIPLC: This routine is called once 
when the STOP/RUN/RESET switch is 
set to the RUN position (warm start). 
You could use it to initialise certain 
variables with a starting value. You 
could also initialise a communication 
link here. The cycle time is not moni- 
tored while this routine is running. 



Figure 2. Monitoring the supply voltage. 


ERRPS: The ERRPS routine is called 
once when the supply voltage is 
turned off or when it falls below a 
critical level. In this routine you could 
store permanent variables (these are 
variables that have to keep their 
value during a power failure) into the 
microcontroller EEPROM. The follow- 
ing example shows how the value of 
the B register is stored in the micro- 
controller EEPROM at address 16 
(see Listing 2). 

ERRCY: This routine is called continu- 
ously when the cycle time has been 
exceeded and the STOP/RUN/RESET 
switch is in the RUN position. This rou- 
tine could be used to light an LED that 
indicates that a program error has 
occurred. This LED should be extin- 
guished again in the INIPLC routine. 


And finally... 

This project forms the basis of a real 
PLC, where you are free to add a large 
number of input and output modules 
according to your requirements. It also 
complies with industrial standards for 
signal interfacing, operation and control. 


The source code for the controller 
firmware has been made freely avail- 
able to Elektor Electronics readers by 
the author. This file can be down- 
loaded from our website under no. 
030158-11. 


( 030158 ) 


N Attention! ]\\ 

This project uses a transformer that is connected to the mains supply. This could have deadly 
consequences if you don't comply with all relevant safety standards. For this reason it's important that 
you follow all instructions shown on the safety guidelines page, regularly printed near the back of the 
magazine. When you use the transformer recommended in this article you can mount the circuit into a box 

that complies with the Class-ll standard. 


56 


elektor electronics - 3/2006 



Listing 3. An 


example of the firmware in the 89S8252. 


; FIRMWARE mC PLC 


WMCON 

.equ 

096H 


P1.0 

.equ 

090H 


Pl.l 

.equ 

091H 


PI. 2 

.equ 

092H 


PI. 3 

.equ 

093H 



■org 

0000H 

start address after a reset 


LJMP 

START 



■org 

0200H 


; RESET mC 
START 

ANL 

WMCON, #11111110B 

disable watchdog 


JB 

PI. 0, SOFT 

jump, software reset 

; HARDWARE RESET mC 



HARD 

CLR 

PI. 2 

disable outputs using PI. 2, because Pl.l will be used to set the reset-flipflop 


CLR 

Pl.l 

set the reset-flipflop 


JNB 

P 1.0, HARD 

jump, wait until the reset-flipflop is set 


SETB 

PI. 2 

enable outputs using PI. 2 


ACALL 

INIUC 

mC initialisation following a reset 


SJMP 

NCYC 


; SOFTWARE RESET mC 



SOFT 

ACALL 

ERRCY 

STOP/RUN/RESET switch in RUN position after the cycle-time was exceeded 


JB 

PI. 2, SOFT 

jump, wait for the STOP/RUN/RESET switch to be in the STOP position 


ACALL 

INIUC 

mC initialisation following a reset 


SJMP 

NCYC 

jump, STOP/RUN/RESET switch was set to STOP 

;PLC CYCLE 
PLC 

JNB 

PI. 2, NCYC 

jump, STOP/RUN/RESET switch is set to STOP 


JB 

PI. 3, NCYC 

jump, faulty supply voltage 


SJMP 

WDTR 

jump, conditions are met to start a new PLC cycle 

NCYC 

ANL 

WMCON, #11111110B 

disable watchdog 


SETB 

Pl.l 

disable outputs using Pl.l 


JNB 

PI. 3, PSOK 

jump, supply voltage OK 


ACALL 

ERRPS 

faulty supply voltage 

PSNOK 

JB 

P1.3, PSNOK 

jump, wait until the supply voltage is OK 

PSOK 

MOV 

R2,#100 

delay: #100 x #50 x 2ms = 10.000ms = 10ms 

DELO 

MOV 

Rl,#50 


DELI 

DJNZ 

Rl.DELl 



DJNZ 

R2.DEL0 



JNB 

PI. 2, NCYC 

jump, STOP/RUN/RESET switch is in STOP position 


JB 

PI. 3, NCYC 

jump, faulty supply voltage 


ACALL 

INIPLC 

PLC initialisation after the STOP/RUN/RESET switch is set to RUN, 
or when the supply oltage returns 


CLR 

Pl.l 

enable outputs using Pl.l, STOP/RUN/RESET switch is set to RUN 
and the supply voltage is OK 


ORL 

WMCON, #11100000B 

WMCON: ms WMCON: ms 

#000xxxxx 16 #100xxxxx256 

#001xxxxx 32 #101xxxxx512 

#010xxxxx 64 #110xxxxxl024 

#011xxxxx 128 #lllxxxxx2048 


ORL 

WMCON, #00000001B 

enable watchdog 

WDTR 

ORL 

WMCON, #00000010B 

watchdog-timer reset 


;PLC PROGRAM 
MAIN 

LJMP PLC ; jump, next PLC cycle 

INITIALISE mC -called once after a hardware reset 
INIUC RET 


INITIALISE PLC (STOP/RUN/RESET switch set to RUN or return of the supply) 

INIPLC RET 

;POWER SUPPLY ERROR -called once after the supply fails 
ERRPS RET 

;CYCLE TIME ERROR (STOP/RUN/RESET switch set to RUN after the cycle-time is exceeded) 
ERRCY RET 


3/2006 - elektor electronics 


57 


TECHNOLOGY 


E-BLOCKS 


Figure 1. 

Initial specification 
sketch. 



John Dobson 




E-blocks SPI Bus Board containing NVM and DAC 


Many of you may be familiar with using the A/D inputs of the PICmicro microcontroller but 
using D/As is less common. This short article examines how it is possible to use Flowcode 
and E-blocks to produce a simple sinewave oscillator for use in testing audio circuits. 


There is often a requirement for a simple sinewave oscil- 
lator you can use for testing audio circuits. The E-blocks 
system includes a D/A converter (DAC) so why not make 
a general-purpose waveform generator with it? 

To start with, you need to decide on the range of values 
you want to produce and do some calculations on the 
overall parameters to check the project is feasible. The 
D/A has an output range of 0 to 5 V in 255 equal steps. 
It does not make sense to go too near the supply rails in 
case some headroom is needed for a buffer device, so to 
keep things simple, go for a maximum of 4 V peak-to- 
peak output. This can be divided down in software to get 



Samples 63 127 191 255 

Angle 7C/2(90°) 71(180°) 371/2(270°) 271 (360°) 


smaller signals. The frequency will need to be around 
1 kHz - that's mid-range audio. A quick check of the 
specification of the MAX5385 D/A states that it has a 
settling time of 20 jis for an output accuracy of "half of 
the least significant bit". If we have 256 samples per 
waveform then this would give us a maximum output fre- 
quency of 200 Hz. In theory that's not high enough, but 
as we are using a sinewave, with small incremental steps 
between samples, the system has a fighting chance of 
coping and we can always resort to reducing the number 
of samples per waveform if it does not perform well. 


Get to grips with D/As 

Good news: D/As are relatively simple to use. You feed 
them a number and the analogue output level equals the 
full-scale voltage output multiplied by a ratio, N, of the 
number you feed in and the full-scale digital input. From 
the graph in Figure 1 you can see an initial sketch 
assuming 5-V full scale output and eight bits (2 8 = 256 or 
0 to 255) input. Actually, the output of the DAC is only 
0.9 V cc so there will be a 1 0% voltage level error in the 
real output, but we can live with that. 

The micro needs to generate a range of values corre- 
sponding to a sinewave output. With 256 steps that 
means 256 separate values. Fortunately, sinewaves are 
symmetrical as well as periodical so we can actually just 


58 


elektor electronics - 3/2006 







generate numbers for a quarter of a waveform and then 
use simple programming to reflect the data horizontally 
and vertically. We want a 4-V peak-to-peak output — to 
make the numbers easy it's best to actually just use a 
range of 200 of the available 256 bits. This will give us 
close to 4 V out of the full (theoretical) 5-V range. The 
core waveform is shown in the bottom left of Figure 1 : it's 
64 values in 'x' with a digital range of 0 to 1 00, or 
around 2 V. 

At this stage we need to use a spreadsheet to calculate 
the numerical output values for the core data. 

The formula for a sinewave is y - sin(x), where x varies 
from 0 to 360 degrees or 0 to 271 radians. Unable to fig- 
ure out how to get Excel to work in degrees here at Elek- 
tor labs we just used radians. We've only shown the first 
three and last three of the 64 core values. To get the val- 
ues you need to send to the DAC, just multiply sin(x) by 
the core range of 1 00. 

Okay, so that's the theory over. 


In practice 

First, let's look at the hardware. We're going to be using 
the E-blocks SPI bus Board shown in the introductory 
photograph. This goes onto the Multiprogrammer board 
which happens to have a PIC16F877 on it. You could 
use almost any PIC with a USART. The SPI board goes on 
port C and we have an LC display on port B and a key- 
pad on port D. 

The SPI board has a MAX5385 DAC as well as a 64- 
kByte SPI bus and non-volatile memory (NVM). You may 
first want to get the data into the NVM. As a future exten- 
sion of the project, consider building up a portfolio of dif- 
ferent waveforms inside the NVM and then call them up 
separately as needed using the keypad and LCD for 
selection. 

To populate the NVM, a program was written that stuffed 
the core 64 data values into the NVM. A counter from 
0-63 was set up, followed by a routine that writes indi- 
vidual bytes of data to sequential NVM locations. In 
Flowcode this is quite easy, you just initialise the SPI bus 
and then write a program with 64 icons, each of which 
writes a byte of data, as shown in Figure 2. 

The next step will be to write a separate program to 
check that the core values produce the first quarter of the 
sine wave. This was fairly straightforward - again a 
counter is established, reading the value from NVM loca- 
tions 0 to 63 in turn, followed by a routine forwarding 
the data from the NVM to the DAC. The Flowcode that 
did it may be seen in action in Figure 3. 

The oscillogram in Figure 4 shows you the first output 
waveform for the first quarter cycle. It's a bit rough 
around the edges but looks like a quarter of a 
sinewave. Unfortunately the time period for a quarter 
cycle was 3 ms - giving a final frequency of under 



Figure 2. NVM stuffing program. 


Figure 3. Simple program to take NVM data and send it to the DAC. 



3/2006 - elektor electronics 


59 




TECHNOLOGY 


E-BLOCKS 



Figure 4. First output waveform showing repeated core values being output. 


Table 1 - output values 

Sample no. 

X 

sin(x) 

1 00sin(x) 

0 

0.024544 

0.024541 

2 

1 

0.049087 

0.049068 

5 

2 

0.073631 

0.073565 

7 

• • • 

• • • 

• • • 

• • • 

61 

1.521711 

0.998796 

100 

62 

1.546255 

0.999699 

100 

63 

1.570798 

1 

100 , 


1 00 Hz; too slow for our purposes. Oh well - we have 
a backup plan. 

Towards the goal 

Things are slowed down by the need to serially read the 
data from the external NVM. However, the '877 device 
we're using also has 256 internal bytes of EEPROM! 
What we can easily do is fill the PIC's internal EEPROM 
with our data, which hopefully will speed up the process 
a great deal. 

A new user macro called LOADEEPROM was added to 
Flowcode. It reads the external NVM and puts the 
64 data bytes into internal EEPROM. Consequently the 
program was altered to read data forwards for the first 
quarter, and backwards for the second quarter of the 
waveform. Next, an offset of 127 is added and the data 
for the second half of the cycle was manipulated simi- 
larly. We then measured the results, which you can see in 
Figure 5. 

The final signal has a period of 2.5 ms or a frequency of 
400 Hz, and a peak-to-peak voltage of around 3.5 V. 

The waveform does not look too distorted although at the 
zero-crossing points you can see a small discontinuity. 

This is presumably caused by program delays between 
each quarter cycle of data being read out. This may be 
solved by loading the internal EEPROM with the full 
256 databytes and start the waveform at 90 degrees 
where distortion will have less effect. Let us and others 
know how you tweaked the project to perfection — post 
your findings with E-blocks in Elektor's online Forum. 

( 065031 - 1 ) 


Earlier in this series 

Electronic Building Blocks, November 2005. 

E-blocks and Flowcode, December 2005. 

E-blocks in Cyberspace, January 2006. 

E-blocks — now you CAN, February 2006. 

Articles may be downloaded individually from our website. 


Figure 5.The final output. 



Programs available 
for download 

SPI memory stuffing.fcf 
First quarter.fcf 
Sine wave gen.fcf 
SPIscreen.FCF 

File number: 065031-1 l.zip 

Location: MAGAZINE — > March 2006 'E-blocks 
Making Waves'. 


60 


elektor electronics - 3/2006 







In all mains-operated equipment certain 
important safety requirements must be 
met. The relevant standard for most 
sound equipment is Safety of Informa- 
tion Technology Equipment, including 
Electrical Business Equipment (Euro- 
pean Harmonized British Standard BS 
EN 60950:1992). Electrical safety under 
this standard relates to protection from 

• a hazardous voltage, that is, a volt- 
age greater than 42.4 V peak or 
60 V d.c.; 

• a hazardous energy level, which is 
defined as a stored energy level of 
20 Joules or more or an available 
continuous power level of 240 VA 
or more at a potential of 2 V or 
more; 

• a single insulation fault which would 
cause a conductive part to become 
hazardous; 

• the source of a hazardous voltage 
or energy level from primary power; 

• secondary power (derived from 
internal circuitry which is supplied 
and isolated from any power 
source, including d.c.) 

Protection against electric shock is 
achieved by two classes of equipment. 

Class I equipment uses basic insu- 
lation ; its conductive parts, which may 
become hazardous if this insulation 
fails, must be connected to the supply 
protective earth. 

Class II equipment uses double or 
reinforced insulation for use where 
there is no provision for supply protec- 
tive earth (rare in electronics - mainly 
applicable to power tools). 

The use of a a Class II insulated 
transformer is preferred, but note that 
when this is fitted in a Class I equip- 
ment, this does not, by itself, confer 
Class II status on the equipment. 

Electrically conductive enclosures 
that are used to isolate and protect a 
hazardous supply voltage or energy 
level from user access must be protec- 
tively earthed regardless of whether the 
mains transformer is Class I or Class II. 

Always keep the distance between 
mains-carrying parts and other parts as 
large as possible, but never less than 
required. 

If at all possible, use an approved 
mains entry with integrated fuse holder 
and on/off switch. If this is not avail- 
able, use a strain relief (Figure, note 2) 
on the mains cable at the point of entry. 
In this case, the mains fuse should be 
placed after the double-pole on/off 
switch unless it is a Touchproof® type 
or similar. Close to each and every fuse 
must be affixed a label stating the fuse 
rating and type. 

The separate on/off switch (Figure, 
note 4), which is really a ‘disconnect 
device’, should be an approved double- 
pole type (to switch the phase and neu- 
tral conductors of a single-phase mains 
supply). In case of a three-phase sup- 
ply, all phases and neutral (where used) 
must be switched simultaneously. A 
pluggable mains cable may be consid- 
ered as a disconnect device. In an 


ELECTRICAL SAFETY 


INFO & MARKET 



1. Use a mains cable with moulded-on plug. 

2. Use a strain relief on the mains cable. 

3. Affix a label at the outside of the enclosure near the mains entry stating the 
eguipment type, the mains voltage or voltage range, the freguency or fre- 
guency range, and the current drain or curent drain range. 

4. Use an approved double-pole on/off switch, which is effectively the ‘discon- 
nect device’. 

5. Push wires through eyelets before soldering them in place. 

6. Use insulating sleeves for extra protection. 

7. The distance between transformer terminals and core and other parts must 
be >6 mm. 

8. Use the correct type, size and current-carrying capacity of cables and wires 
- see shaded table below. 

9. A printed-circuit board like all other parts should be well secured. All joints 
and connections should be well made and soldered neatly so that they are 
mechanically and electrically sound. Never solder mains-carrying wires 
directly to the board: use solder tags. The use of crimp-on tags is also good 
practice. 

10. Even when a Class II transformer is used, it remains the on/off switch whose 
function it is to isolate a hazardous voltage (i.e., mains input) from the pri- 
mary circuit in the eguipment. The primary-to-secondary isolation of the 
transformer does not and can not perform this function. 


approved switch, the contact gap in the 
off position is not smaller than 3 mm. 

The on/off switch must be fitted by 
as short a cable as possible to the 
mains entry point. All components in 
the primary transformer circuit, includ- 
ing a separate mains fuse and separate 
mains filtering components, must be 
placed in the switched section of the 
primary circuit. Placing them before the 
on/off switch will leave them at a haz- 
ardous voltage level when the equip- 
ment is switched off. 

If the equipment uses an open-con- 
struction power supply which is not 
separately protected by an earthed 
metal screen or insulated enclosure or 
otherwise guarded, all the conductive 
parts of the enclosure must be protec- 
tively earthed using green/yellow wire 
(green with a narrow yellow stripe - do 
not use yellow wire with a green stripe). 
The earth wire must not be daisy- 
chained from one part of the enclosure 
to another. Each conductive part must 
be protectively earthed by direct and 
separate wiring to the primary earth 
point which should be as close as pos- 
sible to the mains connector or mains 
cable entry. This ensures that removal 
of the protective earth from a conduc- 
tive part does not also remove the pro- 
tective earth from other conductive 
parts. 

Pay particular attention to the metal 
spindles of switches and potentiome- 
ters: if touchable, these must be protec- 
tively earthed. Note, however, that such 
components fitted with metal spindles 
and/or levers constructed to the rele- 
vant British Standard fully meet all insu- 
lation requirements. 

The temperature of touchable parts 
must not be so high as to cause injury 
or to create a fire risk. 

Most risks can be eliminated by the 
use of correct fuses, a sufficiently firm 
construction, correct choice and use of 
insulating materials and adequate cool- 
ing through heat sinks and by extractor 
fans. 

The equipment must be sturdy: 
repeatedly dropping it on to a hard sur- 
face from a height of 50 mm must not 
cause damage. Greater impacts must 
not loosen the mains transformer, elec- 
trolytic capacitors and other important 
components. 

Do not use dubious or flammable 
materials that emit poisonous gases. 

Shorten screws that come too 
close to other components. 

Keep mains-carrying parts and 
wires well away from ventilation holes, 
so that an intruding screwdriver or 
inward falling metal object cannot touch 
such parts. 

As soon as you open an equipment, 
there are many potential dangers. Most 
of these can be eliminated by discon- 
necting the equipment from the mains 
before the unit is opened. But, since 
testing requires that it is plugged in 
again, it is good practice (and safe) to 
fit a residual current device (RCD)*, 
rated at not more than 30 mA to the 


mains system (sometimes it is possible 
to fit this inside the mains outlet box or 
multiple socket). 

* Sometimes called residual current 
breaker - RCB - or residual circuit cur- 
rent breaker -RCCB. 

These guidelines have been drawn up 
with great care by the editorial staff of 


this magazine. However, the publishers 
do not assume, and hereby disclaim, 
any liability for any loss or damage, 
direct or consequential, caused by 
errors or omissions in these guidelines, 
whether such errors or omissions result 
from negligence, accident or any other 
cause. 


3-core mains cable to BS6500 1990 with three stranded 
conductors in thick PVC sheath 


Max current 

3 A 

6 A 

13 A 

conductor size 

16/0.2 mm 

24/0.2 mm 

40/0.2 mm 

Norn cond area 

0.5 mm 2 

0.75 mm 2 

1.25 mm 2 

overall cable dia. 

5.6 mm 

6.9 mm 

7.5 mm 

Insulated hook-up wire to 

DEF61-12 



Max current 

1.4 A 

3 A 

6 A 

Max working voltage 

1000 V rms 

1000 V rms 

1000 V rms 

PVC sheath thickness 

0.3 mm 

0.3 mm 

0.45 mm 

conductor size 

7/0.2 mm 

16/0.2 mm 

24/0.2 mm 

Norn cond area 

0.22 mm 2 

0.5 mm 2 

0.95 mm 2 

overall wire dia 

1.2 mm 

1.6 mm 

2.05 mm 


3-flat-pin mains plug to BS 1363A 


3/2006 - elektor electronics 


61 






HANDS-ON 


EAVESDROPPING 



Galvanic isolation is a 
special feature of this 
telephone amplifier, which 
includes a line output 
connection for a hi-fi system. 


From an idea by 
Markus Muller 



Although in some countries, including 
the UK and Germany, analogue tele- 
phone connections are something of a 
dying breed, most residential cus- 
tomers use analogue apparatus, even 
in cases where the underlying connec- 
tion is over ISDN. 

There is little reason to change: first, 
ISDN telephones are rather expensive, 
and second, ISDN connection starter 
packs generally include an a/b adap- 
tor which allows the connection of old 
analogue telephones to the ISDN sys- 
tem. What a lot of analogue tele- 
phones lack, and which most modern 
ISDN devices provide, is a loud- 
speaker. 

The experienced Elektor Electronics 
reader will have no difficulty in 
adding a loudspeaker. Several 
designs for telephone amplifiers have 
appeared previously in Elektor Elec- 
tronics, but there has never been a 
circuit to which we cannot make 
some improvements or add new and 
interesting features. 


High Voltage 

The amplifier described here has the 
special feature, not shared by any of its 
predecessors, of a line output. This 
means that it can be connected to an 
ordinary hi-fi system. This requires, as 
a glance at the circuit diagram in Fig- 
ure 1 will show, complete galvanic iso- 
lation between the telephone network 
and the mains. Now we shall look at 
the parts of the circuit in turn. 

The amplifier has two RJ45 telephone- 
style sockets connected in parallel at 
its input, to simplify adding the circuit 
into an existing cabling arrangement. 
An analogue telephone connection 
works essentially as shown in Fig- 
ure 2. In the quiescent state the 
exchange provides a DC voltage of 
nominally 60 V between the a-wire 
and the b-wire. The actual voltage 
level varies significantly with the dis- 
tance from the exchange and can be as 
low as 40 V or as high as 80 V. To ring 
the telephone to signal an incoming 
call, the exchange superimposes an 
AC voltage of up to 75 V on the DC 


level. The peak value of the ringing 
voltage can thus be over 120 V. Despite 
the low current available, this is dan- 
gerous: not just to humans, but also, in 
particular, to connected electronic 
devices. When the receiver is lifted, a 
current of between 10 mA and 30 mA 
flows and the DC voltage falls to 
around 12 V. The analogue voice signal 
is superimposed on this voltage. 
Private telephone exchange systems 
and a/b adaptors can work at much 
lower DC voltages (often 24 V) 
because the distance to the telephone 
itself is much shorter. 

Amplification and filtering 

Of course, the telephone amplifier 
must be designed to work at any of 
these voltages. It is the noble duty of 
input capacitor C2 to isolate these DC 
levels from opamp IC1 (an LF356). A 
high-voltage type is essential, and the 
component recommended in the parts 
list can easily cope with 400 V. 

Next we must ensure that the AC 
component is also reduced to a level 


62 


elektor electronics - 3/2006 








an advanced amplifier 
with line output 


safe for the input to IC1: this is achieved using 
two Schottky diodes, D1 and D2, which limit the 
incoming voltage to between -0.3 V and 15.3 V. 
The current which flows is limited to a safe value 
for the diodes (and for the exchange) by R3. The 
reduced AC voltage (whether it be a ring signal 
or a voice signal) is taken to the inverting input 
of inverting amplifier IC1 via R4. Since the useful 
signal can vary considerably in level, the gain of 
the amplifier can be adjusted between 0 and 2 
(which is slightly lower than might be expected, 
on account of C2 and C4) using potentiometer PI. 
At the same time, a DC voltage of 6.8 V is applied 
to the non-inverting input of the amplifier by volt- 
age divider R1/R2. This voltage can be measured 
for test purposes at the output of the opamp. This 
voltage, which is a little less than half the supply 
voltage, is used at another point in the circuit 
where it is not allowed to exceed 7 V. The output 
swing of the opamp is such that this small asym- 
metry does not matter. 


Since the telephone voice signal is not exactly 
high-quality audio, we can take some liberties 
with it in the interests of reducing the effects of 
interference and noise. The input capacitor, along 
with R3 and R4, forms a high-pass filter with a cut- 
off frequency of 100 Hz, while C3 and R3 form a 
low-pass filter with a corner frequency of about 
17 kHz. And last but not least, C4 also attenuates 
higher frequencies above about 10 kHz (or at least 
those which the opamp is capable of amplifying). 

Galvanic isolation 

To protect the output stages and any electronics 
that may be connected to them, two type 6N138 
linear optocouplers are used to provide galvanic 
isolation up to 2.5 kV. Since the performance of the 
optocouplers is not very dependable (in that their 
characteristics vary considerably from one device to 
the next), we use the rather elegant combination 
of two 6N138s shown to achieve repeatable opera- 



Figure 1. The telephone and audio parts of the circuit are kept strictly separate. 


3/2006 - elektor electronics 


63 



HANDS-ON 


EAVESDROPPING 



Figure 2. AC and DC voltages on an analogue telephone line. 


Measured characteristics 


Characteristic curve A shows the frequency response of the telephone 
amplifier. The measurement was made at the line output, and thus 
corresponds to the values for the loudspeaker output. The upper fre- 
quency range is shown for the two extreme settings of PI, and the 
effect of capacitor C4 is clearly visible. The -3 dB frequency of 
9.9 kHz (at -20 dB) falls to 6.8 kHz when PI is set to maximum. 

At the low-frequency end the effect of the loudspeaker is significant. 
With the loudspeaker connected the corner frequency is 1 40 Hz, 
whereas without the loudspeaker it is 1 00 Hz. Since the output 
impedance of the TDA7052 amplifier effectively attenuates the out- 
put signal by about 1 dB, we have artificially superimposed the 
curves so that they may be compared more easily. 

Here are some of the characteristics as measured on the prototype: 


d 

B 

r 


+3 

-0 

-3 

-6 

-9 

-12 

-15 

-18 

-21 

-24 

-27 

-30 

-33 

-36 

-39 

-42 



Line output (LSI not connected) 


With LSI (8 Q) connected 


Sensitivity 

Maximum output level 
Maximum bandwidth 
Minimum bandwidth 
Minimum THD+N 
THD+N 

Signal-to-noise ratio 
Signal-to-noise ratio 


Full drive, 1 V line level 60 mV 

THD+N = 1 % 1.6 V 

100 Hz to 9.9 kHz 
140 Hz to 6.8 kHz 
B = 22 Hz to 22 kHz 0.26 % 

B = 22 Hz to 22 kHz, LSI = 8 a 1 % 

250 mV in, 1 V out, B = 22 Hz to 22 kHz 55 dB 
250 mV in, 1 V out 57 dBA 


P max (THD+N = 1 %) Voice signal 750 mW 

Minimum THD+N B = 22 Hz to 22 kHz 0.6 % 

Signal-to-noise ratio at 500 mW, B = 22 Hz to 22 kHz 55 dB 

Signal-to-noise ratio at 500 mW 57 dB 

Quiescent current consumption 72 mA 

Current consumption at P max 0.3 A 

Current consumption when overdriven maximum 0.4 A 

Minimum supply voltage 9 V 


64 


elektor electronics - 3/2006 






tion. The optocouplers have a Darling- 
ton pair at the output and are con- 
nected so that the current flowing 
through the output of IC2 is coupled 
back via IC3 to the input of IC2. 
Although this arrangement is slightly 
noisy, the circuit has adequate band- 
width and the gains in terms of linear- 
ity and low distortion more than com- 
pensate. 

The current though IC2 is translated 
into a voltage for the following output 
amplifier by R8. C9 removes the DC 
component of the signal on R8, and 
also forms a second high-pass filter 
with a relatively low corner frequency 
of approximately 40 Hz. This makes the 
overall frequency response of the 
amplifier fairly flat. C8 also reduces 
interference from the power supply, a 
point which we shall return to later. 
As we stated earlier, the gain of the 
input stage of the circuit is approxi- 
mately 2. The attenuation in the opto- 
coupler is approximately 4.7, and so 
the overall gain up to the volume con- 
trol potentiometer P2 is around 0.4. 
This attenuation is not a problem since 
the gain of IC4 (in bridge mode) is 
39 dB. The optimum voltage at the out- 
put of the optocouplers, in terms of 
minimising THD+N, is around 100 mV. 
At this voltage distortion (the second 
harmonic is below -53 dB) is compara- 
ble with the signal-to-noise ratio of 
-55 dB. At maximum volume (P2 at 
maximum), IC4 is overdriven. 


Output amplifier 

The familiar Philips TDA7052 is used 
as an output device in this telephone 
amplifier. This 1-watt bridge-mode 
amplifier has a low quiescent current 
and is thus suitable for battery opera- 
tion. It is powered from the same sup- 
ply as optocoupler IC2. Bridge-mode 
amplifiers have the advantage, when 
used with a single (asymmetrical) sup- 
ply, that they can be connected to the 
loudspeaker without coupling capaci- 
tors; here, however, we go so far as to 
fit two such capacitors — and for a 
good reason! 

The electrolytic capacitors form a high- 
pass filter with a corner frequency of 
slightly less than 100 Hz, thus remov- 
ing the lowest frequencies. In theory 
the corner frequency when using an 
8 Q loudspeaker is 85 Hz, but this 
value depends, of course, on the 
impedance of the loudspeaker. In prin- 
ciple a single electrolytic would work 




Figure 3. The printed circuit board for the telephone amplifier has two ground planes with a 

minimum separation of 6 mm between them. 


[ COMPONENTS LIST 


Resistors: 

R1 ,R3 = lOkD 
R2 = QkQ2 
R4 = 1 00 kD 
R5,R6,R1 1 = lkft 
R7 = 220Q 
R8,R1 2 = 3kQ3 
R9 = 2Q2 
R10 = 2kQ2 
PI = 250kD preset H 
P2 = 10kf2 logarithmic potentiometer, 
mono 

Capacitors: 

Cl = 2|jF2 63 radial 
C2 = 1 5nF 400V 
C3 = 1 nF 400V 
C4 = 68pF 

C5,C1 6,C1 8 = 1 OfjF 63V radial 
C6,C1 0,C1 5,C1 7 = lOOnF 
C7 = 220pF 16V radial (max. diameter 
8mm) 


C8 = 1 nF ceramic (5mm lead pitch) 

C9 = 330nF 

Cl 1,012,013 = 470|jF 1 6V radial 
(max. diameter 8mm) 

Cl 4 = 3nF3 (5mm lead pitch) 

Semiconductors: 

D1 ,D2 = BAT85 
D3 = LED, low current 
D4 = 1 N4002 
IC1 = LF356 

IC2,IC3 = 6N138 (Farnell # 325-831) 
IC4 = TDA7052 
IC5 = NMV0512SA, C&D 
Technologies/Newport Components 
(Farnell # 589-822) 

IC6 = 7806 

Miscellaneous: 

K1,K2 = RJ45 socket 

LSI = 8D / 1 W miniature loudspeaker 

Solder pins 

PCB, order code 030379-1 (see 
Readers Services page) 


3/2006 - elektor electronics 


65 





















HANDS-ON 


EAVESDROPPING 


Optocoupler tolerances 

Optocouplers have wide tolerances. If possible, use a type 6N138 
with a current transfer ratio (CTR) of between 250 % and 450 %, as 
otherwise IC2 and IC3 may attenuate the signal too much. If the volt- 
age across R8 is a few tenths of a volt too low (a tolerance of 1 0 % 
is allowable), its value can be increased to raise the voltage, and vice 
versa. The circuit is so simple that if necessary other standard opto- 
couplers with a Darlington output, such as the IL300, can be used 
with a suitable adjustment to the resistor value. The CTR of IC2 is 
easy to calculate: CTR = (U R8 /R8) / (Ur^/R 6). Changing R8 naturally 
affects the gain of the circuit, although for reasonable adjustments 
this should not cause any problems. 



just as well, but here the required 
capacitance is obtained using two 
capacitors in order to prevent a DC 
level appearing on the line output, 
which is taken from one of the ampli- 
fier’s outputs. Because of this, the gain 
at the line output is only 33 dB. RIO 
ensures that the two electrolytics 
remain charged so that there is no 
‘click’ when an external amplifier is 
connected to the line output. Rll 
makes the output short-circuit-proof, 
and C14 provides additional filtering to 
remove high-frequency interference. To 
prevent undesirable coupling through 
the power supply connections, the 
optocouplers and the amplifier are sep- 
arately smoothed (by R7 and C7, and 
R9, CIO and Cll respectively). 

Power supply 

There is little point in galvanically iso- 
lating the telephone line from the audio 
electronics if their power supplies are 
not also kept separate. To this end we 
use a NMV05125SA DC-DC converter 
which converts an input voltage of 6 V 
to an output voltage of 15 V while pro- 
viding galvanic isolation up to 3 kV. 
The input voltage is a little higher than 
the maximum value of 5.5 V specified 
in the data sheet, but is clearly within 
the ‘absolute maximum rating’ of 7 V. 
In practice, it works well, and thanks 
to the low load, the output voltage is 
slightly higher than the 14.4 V that one 
would expect with an input voltage of 
6 V. The converter presents a rather 
aggressive load to the fixed voltage 
regulator, resulting in an output ripple 
voltage of 0.1 V pp . According to the 
manufacturer’s data, the converter 
switches at a frequency of approxi- 


mately 120 kHz. However, in our labora- 
tory prototype the frequency appeared 
to be a little higher: we measured the 
ripple frequency to be approximately 
300 kHz. This does not affect the per- 
formance of the telephone amplifier, 
but it does simplify the measures we 
need to take in the circuit to suppress 
interference. 

The fixed voltage regulator is the com- 
mon-or-garden 7806, with its input pro- 
tected from reverse polarity connection 
by a diode. The regulator has a drop- 
out voltage of 3 V, and so the input 
voltage obtained from a mains adaptor 
must be at least 9 V. Of course, the 
telephone amplifier can also be pow- 
ered from a battery, although the cur- 
rent consumption is quite high. We 
measured a quiescent current con- 
sumption of 72 mA on the prototype 
(even using a low current LED for 
power indicator D3), with peak current 
up to 0.4 A (using an 8 Q loudspeaker); 
battery operation is thus only appropri- 
ate if the device is to be used occasion- 
ally. In any case, a PP3-style battery 
will not last long, and it would be bet- 
ter to use four AA cells with IC6 
replaced by a wire link and D4 ideally 
replaced by a Schottky diode such as 
the 1N5822 (40 V, 3 A). At 0.4 A this 
Schottky diode drops only 0.3 V, con- 
siderably less than the 0.8 V drop of a 
1N4002. 

Keep your distance 

The steps we have taken to achieve 
galvanic isolation are clear in the 
printed circuit board layout of Figure 3. 
As can be seen, the ground planes for 
the telephone and audio parts of the 


circuit are separated. Populating the 
board should present no difficulties. Do 
not forget the wire links (the circuit 
will work without them, but will be 
more susceptible to interference). 
Sockets should be used for the ampli- 
fiers but not for the optocouplers, so 
that the isolation voltage is not com- 
promised. 

The connection points for the external 
components (potentiometer, line 
socket, loudspeaker and power supply 
socket) lie around the edge of the 
board and should be fitted with termi- 
nal pins. 

The circuit can be built into an ordi- 
nary plastic enclosure, but a metallic 
screen (a piece of tin or unetched 
printed circuit board) should be fitted 
directly under the printed circuit board, 
taking care not to cause a short circuit. 
The screen should be connected to the 
metal enclosure of potentiometer P2 
and to ground. P2 should be fitted as 
close as possible to its connection 
points on the board, and its connection 
wires twisted. 

For best audio results a small, good- 
quality loudspeaker should be used 
inside a large enclosure rather than in 
the electronics box, with the loud- 
speaker being located a few metres 
away from the telephone to prevent 
feedback. Alternatively, the line output 
can be connected to a hi-fi system. 

The circuit discussed in this article is 
not approved for connection to the 
public switched telephone network 
(PSTN) in the United Kingdom. 

( 030379 - 1 ) 


66 


elektor electronics - 3/2006 




Elektor Electronics (Publishing) 

Regus Brentford • 1000 Great West Road 
Brentford TW8 9HH • United Kingdom 
Telephone +44 (0) 208 261 4509 
Fax +44 (0) 208 261 4447 

Order now using the Order Form Email: sales@elektor-electronics.co.uk 

in the Readers Services section in this issue. 


Step into the fascinating world of microcontrollers 



Microcontroller Basics 

Burkhard Kainka 

Microcontrollers have become an indispensable part of modern 
electronics. They make things possible that vastly exceed what 
could be done previously. 

Innumerable applications show that almost nothing is impossible. 
There’s thus every reason to learn more about them, but that 
raises the question of where to find a good introduction to this 
fascinating technology. The answer is easy: this Microcontroller 
Basics book, combined with the 89S8252 Flash Board project 
published by Elektor Electronics. This book clearly explains the 
technology using various microcontroller circuits and programs 
written in several different programming languages. In the course 
of the book, the reader gradually develops increased competence 
in converting his or her ideas into microcontroller circuitry. 



ISBN 0-905705-67-X 


Flash Microcontroller 
Starter Kit 

Elektor Hardware & Software 

Step into the fascinating world of microcontrollers with 
the Elektor Electronics Flash Microcontroller Starter Kit. 
Order now the ready-assembled PCB incl. software, cable, 
adapter & related articles. 

Contents of Starter Kit: 

• 89S8252 Flash Microcontroller board 
(ready-assembled and tested PCB) 

• 300-mA mains adapter 

• Serial cable for COM port 

• Software bundle on CD-ROM 

• Article compilation on CD-ROM 


230 Pages 
£18.70 / US$ 33.70 



£69.00 /US$112.50 


More information on www.elektor-electronics.co.uk 










KNOW-HOW 


MOTORS 




and their modern applications 

Dr. Thomas Scherer 



A linear motor is simply one which produces motion in a straight line rather than in a cir- 
cle. We give an overview of the technology and its applications, including examples of 
genuine' linear motors and related devices. 


Although space does not permit a full introduction to 
electromagnetic theory in this article, we should men- 
tion that there are linear drive systems where electricity 
is turned into motion in a straight line which we never- 
theless do not count as genuine linear motors'. These 
are so-called dynamic actuators which operate on a 
very simple principle using a magnet and a coil, and 
which have long been used in various applications. 

A good example of this type of drive is the classical 
dynamic loudspeaker. Figure 1 is a diagram of its 
construction. Its operation is simple and well known: a 
coil in a magnetic field experiences a force propor- 
tional to the current flowing in it. Apart from applica- 
tions in sound production, this principle has been in use 
for almost 20 years in the positioning mechanisms for 
read/write heads in hard disk drives. Once capacities 
exceeded 40 Mbyte and track widths shrank, a more 


precise head drive mechanism was required than the 
rotary stepper motor design like that used in floppy disk 
drives. Under control of specially-designed position sen- 
sors, the 'voice coil' mechanism, as it is known, 
achieves previously unattainable tracking precision 
and, thanks to the high force available, fast seek times. 
In machine tools actuators are starting to be used for 
simple and short linear motions, replacing pneumatic 
systems. In these, the roles of coil and magnet are 
reversed: the coil is fixed and the magnet or piece of 
metal moves. In contrast to pseudo-linear actuators, 
where the linear motion is derived from the rotation of a 
conventional electric motor using a rack and pinion or 
a belt drive, these solutions have the advantage of 
being smaller and simpler. 

Further advantages include less wear and tear, high 
power and consequent ease of use and reliability. Since 


68 


elektor electronics - 3/2006 





pseudo-linear motors are cheap to produce and can act 
over greater distances, they will still have their applica- 
tions in machine tools. 


Genuine linear motors 

A genuine linear motor differs from its rotary cousins sim- 
ply in that the stator (the outer cage within which the 
rotor turns) is flattened out. The rotor then becomes an 
object which moves along the stator rails or which 
encloses the one-dimensional stator. Since the translatory 
motion in a particular direction is produced without the 
use of rack and pinion mechanisms or the like, this kind 
of drive is often simply referred to as 'direct drive'. 

Therein lies the chief advantage: with many fewer mov- 
ing parts there is much less wear and tear and practically 
no play in the mechanism. This all leads to very high reli- 
ability. 

It is interesting to note that the principle has been known 
for over 150 years, although industrial use has only 
been widespread for the last 30 years or so. This is 
because the great position sensing precision required for 
machine tools, in the micrometre range, has only recently 
become achievable using specially-designed semiconduc- 
tor sensors and high-speed electronic motor controllers. 
The enormous power available (accelerations of 20 g 
and more can realistically be achieved in practice) make 
linear motors a good choice more generally, where rota- 
tional motion is not needed. 

In theory all the principles employed in rotary electric 
motors, including stepper motors and three-phase 
machines, can be applied to linear motors. And, depend- 
ing on the application, these motors can be bought off- 
the-shelf in a range of power output levels, maximum dis- 
placements and physical constructions. This includes vari- 
ants with stationary or moving windings, with permanent 
magnets or electromagnets, and exotic designs for spe- 
cial applications. 


Rail guns and catapults 

Few technological advances escape application to 
destructive ends, and linear electromagnetic drives are 
no exception. Figure 2 shows a schematic diagram of a 
gun-like device which, because of its construction, is 
known as a 'rail gun'. A conductive projectile slides 
between two copper rails and experiences acceleration 
when a current flows. During the second world war Ger- 
many tried (without success) to construct weapons using 
this very straightforward principle. Fortunately such 
weapons are not widely used even today, because of the 
extremely high currents (thousands or millions of Amps) 
involved and the great forces that the components of the 
weapon must withstand. 

Using a electromagnetically-propelled projectile as a 
large-scale catapult is an area of military research. In 
principle, a catapult would be an ideal way of launching 
a high-speed aircraft using a scramjet engine. Scramjet 
engines only start to operate when a relatively high mini- 
mum speed is exceeded, rather more than the speed of 
sound. Experiments to date using working prototypes use 
a supplementary rocket engine, or the prototype is piggy- 
backed on a conventional military aircraft and taken to a 
great height: it is then allowed to fall until it reaches the 
required speed for the engine to start. With scramjets 
capable of a speed of up to Mach 1 5, it is technically 
reasonable to use a catapult to accelerate them up to sev- 
eral times the speed of sound and start them. It is at least 




iiroci 


rnurjnel 


Figure 1. 

Principle of the dynamic 
loudspeaker. This type 
of drive is used in 
actuators in industrial 
applications. 


magnetic 

field 



curreni 

flow 



Ff[?jfiorile 


Ldf&fii 

lores 



magnei;c 

fi^Jd 


Figure 2. 

The 'drive' in a rail gun 
is very simple. Two 
current-carrying rails 
and a conducting 
projectile are all that is 
required. 



Figure 3. 

The linear motor in a 
catapult. Propulsion 
and guidance coils 
allow a metal saddle to 
be accelerated and keep 
it on its track. (Source: 
Schwandt Infographics) 


theoretically possible to achieve this using high-powered 
linear motors (Figure 3). NASA has already produced a 
number of small-scale working research models, spon- 
sored by the military. The system is still, however, science 
fiction, since the forces cannot be properly controlled, it 
is extremely expensive and humans are not capable of 
surviving the necessary accelerations unharmed if the cat- 
apult track is short (less than 10 km in length). Practical 
applications of linear motors to the transport of human 
beings are taking a different course. 


The Transrapid 

Relatively high speed trains can be constructed using con- 
ventional rotary motors and wheels on rails: the Japanese 
Shinkansen bullet trains, the German ICE and the French 
TGV can reach speeds of over 300 km/h. At higher 
speeds special track must be laid and wear and tear 
from friction become significant. An experimental version 
of the TGV in 1 990 reached an incredible 5 1 5.3 km/h, 


3/2006 - elektor electronics 


69 



KNOW-HOW 


MOTORS 


Figure 4. 
Propulsion and 
guidance system of the 
Transrapid train in cut- 
away view. (Source: 
Siemens AG) 



although at these speeds the overhead wires and pan- 
tographs required maintenance after just this one journey. 
Magnetic levitation railways experience no wear and 
tear due to friction and it is natural to propel a magneti- 
cally-levitated train using a linear motor. Practical ver- 
sions of this idea are the Japanese JR-Maglev and the 
German Transrapid. Decades of research have gone into 
both systems. The Transrapid has been in regular opera- 
tion in Shanghai for almost two years and has already 
transported over a million passengers over its 30 km 
route at some 430 km/h. Both systems are designed for 
practical use at around 500 km/h and in principle could 
be run even faster. Consideration is being given to 
installing a stretch of Transrapid track in the Netherlands 
(see http://www.magneetzweefbaan.nl/ magneetzweef- 
baan/Default.asp?p=l 7); in Germany there is still only a 
prototype track at Emsland in Lower Saxony. 


Levitation technology 

In the Transrapid design levitation and propulsion are 
combined. Figure 4 shows a cross-section of the track 
and levitation/propulsion system of the train. On the left 
and right of the track there are metal plates upon which 
the guidance electromagnets act. The electromagnets 


Figure 5. 
Under the covers of the 
propulsion and guidance 
system of the 
Transrapid train. 
(Source: Siemens AG) 



responsible for lifting the train act on the laminations 
which form the flat stator built into the underside of the 
track on the left and on the right. The air-gap, electroni- 
cally controlled from within the train itself, is just 10 mm. 
The windings responsible for propulsion are incorporated 
into the laminations, made of an isolated aluminium 
cable with a cross-sectional area of some 300 mm 2 . The 
whole thing functions in the same way as a three-phase 
synchronous motor laid flat. A travelling magnetic field is 
induced in the windings in the track. If there is a current 
in the lifting magnets, they, and hence the train, are lifted 
up. Since the train envelops the track, it is practically 
impossible for it to become derailed. Figure 5 shows a 
view of the actual construction with the covers removed. 
Each train or carriage is independently levitated and pro- 
pelled by the track. There is thus no separate locomotive 
to pull or push the train. The speed of the train is directly 
related to the frequency of the alternating currents sup- 
plied to the windings, reaching 300 Hz for a speed of 
approximately 550 km/h in the case of the Transrapid. 

It is worth asking how the 1 0 mm air gap can be main- 
tained at these speeds. The gap is inductively measured 
thousands of times per second by each segment of the 
train and the currents in the guidance and levitation elec- 
tromagnets correspondingly regulated. Taking into 
account the mass of the carriage a practical control fre- 
quency is around 30 Hz. To levitate one segment of the 
train and guide it around a curve of track requires an 
electrical power of between 55 kW and 1 1 0 kW, 
depending on load. The necessary energy comes from a 
suitably-dimensioned battery which is capable of main- 
taining levitation for approximately one hour if power is 
lost. If the battery becomes discharged the train lowers 
itself onto runners. The battery is inductively charged 
from harmonics of the magnetic propulsion field when the 
train is travelling at over 100 km/h. 

A train composed of three segments requires a drive 
power of up to 45 MV A at a speed of 500 km/h. So that 
the whole track is not always powered, it is divided into 
many short sections selectively driven by inverters placed 
along the track. The inverters are constructed using 
power semiconductors such as GTO (gate turn-off) thyris- 
tors and IGBTs (insulated gate bipolar transistors) operat- 
ing at voltages of over 4000 kV and currents of over 
1 kA each. The inverter stations control both frequency 
and voltage and receive commands from a central con- 
trol station for the track. The Transrapid therefore does 
not require a driver on the train. 

The modern traveller will naturally be concerned as to 
whether his laptop will operate correctly or whether the 
data on the magnetic stripe on his credit-card will survive 
in the neighbourhood of such high-energy magnetic 
fields. Since the air gap is relatively small at 1 0 mm the 
stray magnetic fields are kept to a minimum and the field 
inside the passenger compartments is comparable in 
magnitude to the natural magnetic field of the earth. 
Things are rather different in the case of the Japanese JR- 
Maglev system where the train rides on a repelling mag- 
netic field. This demands a greater air gap in the region 
of 1 0 cm, creating stray fields up to a thousand times 
greater than those of the Transrapid. 

Of course, we have not been able to cover all the details 
of the systems here. More in-depth information can be 
found by searching the Internet using keywords such as 
linear motor', 'rail gun', 'scramjet', 'transrapid' and 
'maglev'. Wikipedia also has a considerable amount of 
useful information. 

( 050374 - 1 ) 


70 


elektor electronics - 3/2006 







B mfLtlli 









E-blocks Easy Internet Kit 

Connect your blocks to the internet 

E-blocks are small self-contained electronic 


E-blocks Easy CAN Kit 

A complex system made transparent 


The CAN bus is a resilient, high data rate bus for 
communicating between electronic devices in 
situations where high data reliability is required. 
One use of the CAN bus is in the automotive 



circuits and printed circuit boards that can * * . 

be combined to create functioning electronic /W _ L- . ~ jS 
applications and systems. With the E-blocks In- 
ternet board you can connect your own system 
to the Internet. This module is perfect to quickly 
addasimplewebpagetoyourembedded system. Thisthen permits (measu- 
rement) data to be inspected remotely. Applications include reading out a 
weather station, switching lighting systems and monitoring and controlling 
machines! The application area is truly spectacular! 


industry where it is being used as a substitute for 

copper wiring looms in cars. The E-blocks Easy 

CAN Kit allows you to employ this professional bus system in your own 

applications. Implementing CAN is a complex task in languages like C, 

but doing so with Flowcode and E-blocks is actually very simple. As a 

special offer to encourage you to investigate CAN we are making available 

an E-blocks Easy CAN kit at 30% discount. An offer you CAN’t resist! 


E-blocks Easy Internet Kit: 


Flowcode Professional 

£118.00 

E-blocks LED board 

£ 14.65 

E-blocks LCD board 

£ 19.30 

E-blocks USB Multiprogrammer 

£ 77.30 

E-blocks switch board 

£ 14.65 

E-blocks internet board 

£ 71.95 

PIC16F877 

£ 10.50 

Ethernet ‘crossover’ cable 

£ 5.30 

Total value: 

£331.65 

Special Offer: \ 30 % L 

/ d\sco«°y> 

£ 232.50 


E-blocks Easy CAN Kit: 

Flowcode Professional 


£118.00 

E-blocks LED board 


£ 14.65 

2 x E-blocks LCD board 


£ 38.60 

2 x E-block USB Multiprogrammer 

£154.60 

E-blocks Switch board 


£ 14.65 

2 x E-blocks CAN board 


£ 67.00 

2 x PIC16F877 


£ 21.00 

Total value: 

V 


£428.50 

\ 

Special Offer: 

/ 

\ 30 °/° L 

d\sc° u ”>> 



Ordering 

Use the order form at the back or go to www.elektor-electronics.co.uk 
E-blocks will be shipped after receipt of payment. 

Prices are exclusive of postage. 


Learn more about E-blocks? 

For more information, visit www.elektor-electronics.co.uk/eblocks 















HANDS-ON 


DESIGN TIPS 


Energy recovery 


+U B 

(±> 


RE1 


D1 


ED X 


S ? NAL Ri ✓TV 1 


< 2 > 


050310-11 


Peter Lay 

Energy is becoming more and 
more expensive, and so we are 
always on the lookout for ways to 
save energy in circuits. The 
author has decided to look at 
how to recovery energy from a 
relay switching circuit. 

If a relay is driven by a transistor 
switching stage it is usual to con- 
nect a flywheel diode in parallel 
with the coil to short out the back 
EMF produced when the relay 


2 


+u B 



RE1 

[±] 




® 

050310-12 


+u B 



current is switched off (Fig- 
ure 1). If an LED is wired in 
series with the flywheel diode 
(Figure 2) it will flash every time 
there is an inductive spike with 
the transistor turns off. The dura- 
tion and brightness of the flash 
(and indeed, whether the spike is 
large enough to destroy the LED!) 
depend on the rate of change of 
the current in the relay coil and its 
inductance: 

Uj = -L di / dt 


So far we have not actually recov- 
ered any energy. Figure 3 
shows a theoretical design where 
the energy stored in the relay coil 
is recovered so that it can be 
used to supply a (low-power) cir- 
cuit. The greater the inductance 
of the coil and the more fre- 
quently it is switched, the more 
energy is stored in capacitor C. 
The zener diode (in series with 
the flywheel diode) limits the max- 
imum voltage to which the capac- 
itor can be charged. Measured 


relative to ground the open-circuit 
voltage at point A is the sum of 
the capacitor voltage due to the 
recovered energy and the supply 
voltage. In particular, the voltage 
at point A is higher than the sup- 
ply voltage. 

The author would be interested in 
discussing these ideas further with 
readers. His e-mail address is 
info@peterlay.de. 

( 050310 - 1 ) 


FBI siren with flashing light 



Arthur Schilp 

This ultra-simple circuit will pro- 
duce the familiar sound of sirens 
used by US police cars on emer- 
gency calls. A small lamp will 
also flash synchronously with the 
siren sound. The circuit is capa- 
ble of powering loads greater 
than 1 A for one or more lamps 
or a powerful loudspeaker, the kit 
producing quite a bit of noise 
and light. 

The circuit is built from two 
astable multivibrators, in this case 
the familiar 555 of which two are 
present in an NE556 case. Of 
course, you are free to use two 
555s if that suits you better. Both 
timer ICs are configured to oper- 
ate as astable multivibrators. 

The first timer is configured with 
R 1 , R2 and C2 to supply a rec- 
tangular signal of about 2 Hz at 
pin 9. The lamp is switched on 
and off by way of power transis- 


tor T1 . The second 
555 is configured 
using R4, R5 and 
C5, and supplies a 
square wave at 
pin 5 that drives the 
loudspeaker. The 
toggling voltage at 
the output of the first 
timer (pin 9) causes 
electrolytic capacitor 
C3 to be partly 
charged and dis- 
charged, periodi- 
cally, via resistor R3. 

C3 is connected to 
the control input of 
the second timer 
(pin 3), causing it to 
work as a VCO 
(voltage controlled 
amplifier). The 
upshot is that the fre- 
quency of the 
square wave applied to the loud- 
speaker rises and falls periodi- 
cally, rendering a good imitation 
of the wailing sound of the US 


police car siren (we hear too 
often in movies). 

The small number of dead-stan- 
dard components used enables 


this circuit to be built on Ver- 
oboard without problems. 

( 050349 - 1 ) 


72 


elektor electronics - 3/2006 




Energy saver for relays 


Klemens Viernickel 

When dealing with relays we dis- 
tinguish between the pull-in volt- 
age and the hold voltage. 
Depending on the type of device, 
the latter is from about 1 0 % to 
50 % lower than the former. This 
means that once we have safely 
pulled in the relay armature we 
can drop the coil voltage to its 
hold value, thus reducing the 
power dissipated. The simple cir- 
cuit shown here does just that: it 
consists of a parallel combination 
of an LED, an electrolytic capaci- 


tor and a resistor, together placed 
in series with the relay coil. As 
well as saving energy by reduc- 
ing the operating current of the 
relay and increasing its operating 
life the circuit also has the advan- 
tage of providing a status indica- 
tor in the form of the LED. 

The author has used this circuit 
with practically all types of relay, 
with various rated currents and 
voltages. The recommended com- 
ponent values are as follows: 

• The electrolytic capacitor 
should have a value between 
100 |jF and 1000 |jF with a 


working voltage of 6.3 V, 
depending on the rated current of 
the relay coil. 

• The resistor value should be 
between 1 0 Q and 1 k£2 so that 
in the active state a current of 
20 mA flows through the LED. 

• A standard green or yellow 
LED with a rated forward current 
of 20 mA should be used. When 
using relays with a very low coil 
current low-current LEDs may be 
substituted. Add a zener diode in 
series for higher coil voltages 
such as 24 V or 48 V. 

( 050201 - 1 ) 



Opamp with increased output current 



Klemens Viernickel 

Integrated opamps offer advan- 
tages such as ease of use, good 
price-performance ratio and 
small physical size. However, 
they seldom have an output cur- 
rent drive capability of greater 
than about 12 mA, and so they 
are not suitable for use in 20 mA 
current loop applications, for 
example. One solution is to add 
a driver stage with the necessary 
output power, comprising per- 
haps two to four transistors and a 


number of other components. 
This design takes up board 
space and is relatively expen- 
sive, tending to offset the advan- 
tages of the integrated device. 
An alternative possibility is to 
boost the output drive capability 
by connecting opamps in paral- 
lel. The output current will then 
be approximately proportional 
to the number of opamps. 
Instead of a single opamp a 
dual or quad device is used to 
achieve greater output power. 
The idea is shown in Figure 1 . The 


output of the first opamp is con- 
nected to the input of a further non- 
inverting opamp stage as well as 
being connected to the output of the 
circuit via a resistor. The first opamp 
thus drives the second non-inverting 
amplifier which provides all the out- 
put current of the circuit as long as 
that remains within its normal capa- 
bility. As the output current demand 
increases the second opamp will 
reach the limit of its drive capabil- 
ity. Its gain will then fall off and a 
voltage difference will develop 
across its inputs. The first opamp 


will then start to deliver more and 
more current to the output via the 
resistor, and the sum of the output 
currents of the two opamps thus 
flows through load resistor R[. 

By adding another resistor we can 
compare the current contributions 
from the two opamps (Figure 2). 
The complete circuit with two 
opamps is shown in Figure 3. 
The principle of the circuit can be 
extended to more opamps with 
their output currents being added 
together (see Figure 4). 

( 050201 - 2 ) 



3/2006 - elektor electronics 


73 


INFO & MARKET 


E-CAD DVD 




Larry Kossek 


CAD Software 
for electronics 



Schematics, 
PCB Design, 
Simulation 


We recently featured a readership survey on 
our website to invite feedback on the DVD 
which accompanied the November issue 
of Elektor Electronics. This free DVD 
was a new departure for us and we 
were very grateful for both the posi- 
tive and negative comments which 
landed on our (virtual) doormat... 


Enthalt Info- bzw. 
Lehrprogramme 


Elektor 
lektuur 

© 2005 Segment B.V. 


In November 
2005 we included a 
free DVD with a collection of programs for circuit capture 
and PCB development/layout along with our magazine. 
We were keen to gauge your opinion so a readership 
survey appeared for a few weeks on our website at 
www.elektor-electronics.co.uk. 


On the positive side 


without additional expense. The relative merits of the 
different programs can be more easily judged to deter- 
mine which is more suitable". 

The selection of programs was also well received "The 
DVD provided me with a good selection of the software 
available without the need for lengthy downloads over 
the Internet (not much fun for a 15 MB program with any- 
thing less than broadband]" . 

Students on the whole gave an enthusiastic response and 
even some lecturers commented that "the DVD contained 
some tools which we could incorporate on some of our 
courses at College and University". 

The inclusion of KiCAD was appreciated; it has many fol- 
lowers and can run in either a Windows or Linux environ- 
ment. Apple users were also surprised to find something 
for them on the disk: " Excellent , there's even a Mac pro- 
gram on there!" 


Comments ranging from " Excellent initiative, many 
thanks" to "Thanks very much , I'm a new user , very inter- 
esting" indicated that many of you thought the DVD was 
a good idea. Appreciative readers also responded: "This 
compilation has saved me many hours of work" or "Now 
I have a complete collection of the programs on one 
disk" 

Although duly announced on our website and in the 
October 2005 issue, the DVD give-away came as a com- 
plete surprise to many readers. The disk was praised for 
containing "a good cross section of the tools available". 
Several readers commented that they had bought the 
November issue just for the DVD: "The DVD alone was 
worth the cost of the magazine. It has allowed me to 
make a practical comparison of the available software 


Whether the opportunity to compare many different pro- 
grams actually led to users switching to a different pro- 
gram package is uncertain. Many comments were along 
the lines of: "Interesting and informative but I will con- 
tinue to use the program that I am familiar with. Using 
other programs only causes a lot of confusion. I am sure 
that better software is available but I prefer to stick with 
what I know". 

One reader mentioned that he had tried out an idea for 
a front panel design using Frontdesigner from Abacom 
and liked the result so much that he went ahead and 
purchased the program immediately after using it for the 
first time. 


74 


elektor electronics - 3/2006 






Eagle 

No Responses 

SPIan & SPrintLayout 
Target 3001! 

OrCAD 
Proteus 
KiCAD 
Layo PCB 
Design Suite 



Table 1 


The Eagle has landed 

Of all the software on the DVD Eagle was, on average 
voted the most popular across all four language web- 
sites. The UK response shows an anomalous preference 
for KiCAD but this was probably due to enthusiastic 
KiCAD fans having teamed up to push the survey results 
in a certain direction. 

The overall results are collected together in Table 1 . 
What is not shown on the table is the interest expressed 
by our readers in so many different programs. 

Here we can ascertain that around 60 % of the UK read- 
ership indicated that their favourite program was for pri- 
vate use. It was also noted that the software used at home 
was not always the same software as that used at work. 
When choosing a program the software costs were con- 
sidered to be an important factor but not as influential as 
the opinions of colleagues and friends who were familiar 
with the software. The simplicity of the user interface is 
also an important factor; the faster you can begin getting 
results with a program the more you tend to like it. 

The majority of respondents were satisfied or more than 
satisfied with the programs they were using. Some 1 0 to 
1 8 % thought that there was probably a better solution 
that they had not yet found. These readers were particu- 
larly grateful for the free DVD in the November issue. 


Suggestions and comments 

It was clear from the start that we wouldn't be able to pro- 
vide a copy of every available layout program on our 
DVD. Many of you suggested Altium - Protel, Auto- 
TRAX EDA, DipTrace, DouglasCAD, Express PCB, 
PADS, SupermaxEGAD, TINA simulator and Vir- 
tual Breadboard etc. As reported in Mailbox, a number 
of CAD software manufacturers simply declined our offer 
to have a demo or trial version of their product included in 
the DVD. One reader would have liked a copy of Scooter 
while another would have appreciated comments about 
the 100-euro version of BAE. Circuit simulation software 
was not included on the DVD but an overview of the topic 
may be the subject of a future DVD... 

Other respondents commented that they were not aware 
of the existence of some of the programs and were grate- 
ful for a chance to try them out. 

One parent suggested that it may have been useful to 
include some simple PCB layout tools that could be used 
by, say, a 1 2 year old. This excellent suggestion has 



niLj flnucnn 
n - jfl&c- 

U 5P.JU1 A r.P'm waul 
QTfl'Uffl KMr 
■OtGAD 
nrwv.niK 
HHCAC 
□ L» yn TCB 


nrw-i.y. s.vtA 


Figure 1. 

Program popularity 
amongst the four 
European Elektor 
Electronics websites. 




0% 


50% 


100 % 


□ Hobby 
■ Pro 

□ Mo 
resp 


Figure 2. 
User profile 


3/2006 - elektor electronics 


75 






INFO & MARKET 


E-CAD DVD 


been noted and will no doubt be considered when we 
next get the opportunity to make similar offers. 

A KiCAD enthusiast has suggested that we run a tutorial 
series on this software, good idea, any volunteers out 
there willing to take this on? 

Some programs received critical remarks, the latest offer- 
ing from Protel for example attracted a number of nega- 
tive comments while another reader observed that: 
"Boordmaker Win is far too expensive for private use!!” 

It came as no surprise that the most popular programs 
attracted praise (e.g. EASY PC), and especially SPlan 
and Sprint Layout were often mentioned. 

"SprintLoyout fulfils my requirements more precisely than 
any of the other programs ". 

One reader suggested that a future DVD might feature 
PC-based test equipment and circuit simulation software. 
Another reader thought a DVD containing programming 
tools and program development environments would be 
useful. These suggestions have been noted and may be 
incorporated in future DVDs. 

Some readers commented that most of the programs are 
demo versions so it is difficult to make a meaningful com- 
parison between the software especially if you are not 
aware of the price of the full software package: "it would 
not be fair to compare a 200 pound program with a 
10,000 pound without taking into account the price of 
the software. " 

We would beg to disagree on this point and suggest that 
program comparisons are more likely to be 'objective' if 
the cost of the software is not considered. However we 
take on board that it may have been useful to include a 
table indicating price / demo / freeware information. 

You can't please everyone... 

Negative reactions were also registered, some readers 
complained that the DVD was missing from their issue 
and these have hopefully been supplied free of charge 
from the publishers by now. 

Some readers reported that they could not run the DVD. 
Many of the problems turned out to be "user induced" 
ranging from surprise when their CD-ROM drive was 
unable to run the DVD (I must admit I fell into this trap 
when I tried to run the DVD at home on my ancient lap- 
top) to "/ can't see anything on the TV when I plug the 
disk into my DVD player” a mistake which can probably 
be attributed to the effect on the brain of too much party- 
ing in the run up to Christmas. 

Disks damaged in transit were quite rare and have been 
replaced. 

Some of the more extreme reactions included comments 
that the DVD was "completely unnecessary " or "totally 
useless ". Other comments judged the disk contents to be 
"meagre”. 

One problem that we cannot be held responsible for is a 
symptom of the well known "Windows disease". It is pos- 
sibly one of the most frustrating features of some Win- 
dows programs that after trialling software and subse- 
quent de-installation, traces of the original program can 
still be found on the computer and are notoriously difficult 
to remove. This is however not the case for all programs, 
some are more well behaved than others. 

A number of you would have liked to see a more 
detailed article accompanying the disk: "It was disap- 
pointing that the comparisons were sketchy and inade- 


quate, but nevertheless it was a splendid effort 
regardless " Another commented: "many of the programs 
require a large investment of time and the limited nature 
of the demo software means that it was not worth the 
time and effort." Reading between the lines it seemed 
that many respondents were looking for advice on 
the best system to purchase, but such recommenda- 
tions were not what we intended and are anyway 
almost impossible to make for this type of software. 
Many had hoped for fuller versions of the software but 
we can only pass on the version which is supplied to us. 

It will only take one publisher to release a freeware ver- 
sion with more features for the others to follow suit to 
maintain market share. 


A tale of woe 

Quote: "/ have been using the program Capture and 
Layout for a number of years and from day one I 
have been looking forward to the next software 
release that would surely improve the program. 
Unfortunately it has not been such a simple proce- 
dure; Features that were good in the previous ver- 
sion of the software have been omitted in the latest 
version. Known bugs were fixed but it seemed like 
just as many new bugs were introduced! Multiple 
' undo's' are implemented in Capture 10.0 but only 
work for a few, less important commands. In Lay- 
out, like previous versions there is only one or no 
step forward or back. This problem was identified 
in a review of the program in Elektor Electronics 
many years ago. This has been my experience with 
a CAD program made in the USA." 

Who would have thought that PCB layout could be such 
a headache? 

Taking into account the positive and negative comments it 
seems that on the whole the disk was received favourably. 
We have gained much from this experience and once 
again would like to thank all those who participated. 

( 050323 - 1 ) 



76 


elektor electronics - 3/2006 





RETRONICS 


INFOTAINMENT 


Elektor Plotters ( 1 988- 1991) 




Jan Buiting 

This story starts in May 1988 
with the publication of an article 
with the delightfully simple and 
technically correct title 'Plotter 
(part 1 )". The design was based 
on a mechanical drawing and 
an accompanying letter sent to us 
by one J. Arkema from the 
Netherlands. This was at a time 
that plotters were noisy, slow and 
expensive PC adjuncts only seen 
in the cellars of professional engi- 
neering bureaus running Auto- 
CAD or similar programs. Of 
course, the electronics hobbyist 
had different things in mind to do 
with a plotter, if only he could get 
his hands on one: drawing 
schematics and 'printing' PCB 
artwork! Unfortunately, to this 
day a working high-end plotter, 
particularly one of Hewlett 
Packard, is a fairly rare find. 

The proposed plotter, then, was a 
simple X-Y type, with the Y move- 
ment carried out by a platen mov- 
ing the paper sheet (up to A2 


size!), and the X motion handled 
by a pen carriage covering a 
span of about 50 cm along a 
guide bar. The May 1 988 article 
came with a set of mechanical 
drawings of the (mostly alu- 
minium) parts to cut, mill, drill and 
file before you could even start 
dreaming of assembling the plot- 
ter. These drawings were pro- 
duced manually on an ordinary 
drawing stand. It turned out a 
quite unusual job for our drawing 
staff, and it took several versions 
before a 'blueprint' was pro- 
duced that could be read by 
someone accustomed to working 
with a lathe. Mind you, no plotter 
was available, let alone a pro- 
gram or a PC. 

Unfortunately, despite the efforts 
that went into producing the 
drawings, a poor balance was 
struck between the mechanical 
construction (wrapped up in 
about two pages) and the elec- 
tronics we all understood so 
much better. Although a mechan- 


ical parts list was printed and an 
artist's impression of the assem- 
bled plotter, we were inundated 
with questions like 'how to 
assemble the thing' and where to 
obtain Skiffy parts, Binder mag- 
nets, Berger stepper motors and 
Rotring pen refills. Fortunately, 
one of our advertisers, Meek-it 
from The Hague, Holland, 
stepped in and offered a kit of 
parts to build the plotter. 

After al the hubbub around the 
mechanical construction, silence 
reigned when we published 
part 2 of the article in June 1 988. 
In it, we duly described the algo- 
rithms that (we assumed) would 
enable talented readers to write 
their own drivers to control the 
plotter from a PC. A wrong 
assumption, as virtually no 
response was received and for 
quite some time it seemed that no 
one had the fuzziest notion of 
what we meant by octants, step- 
per motor look-up tables and 
MC3479 control bytes, let alone 
Bresenham's algorithm. 

The silence was broken in March 
1 990 when we were finally able 
to publish "Plotter Mark 2", dis- 
cussing a few mechanical 
improvement to the original 
design but more importantly a 
'partly HPGL compatible' driver 


for PCs! The program from B. 
Lewetz was called Mondriaan 
after the Dutch artist (1877- 
1944). Although it supported just 
six basic commands from the 
much larger HPGL set, the pro- 
gram effectively made the project 
come alive after a two year wait. 
Reader response was overwhelm- 
ing as the missing link between 
hardware and software had been 
catered for at long last. The 
famous 'Columbia' and 'nozzle' 
drawings were supplied with the 
program, along with a few pen 
calibration and plotter test files. 
Market leading programs like 
Autocad and Autosketch at the 
time employed only six HPGL 
commands so the Elektor plotter 
did just fine on the Centronics 
port. In the UK, Cliff Gregory 
optimised the mechanical design 
of the Elektor plotter and started 
to supply 'Plotter Mk3' kits com- 
prising ball bearings and stainless 
steel parts. 

Finally, in September 1991 we 
published another plotter driver, 
this time written in Turbo Pascal 
and supporting 17 HPGL com- 
mands. Supplied on a 360 kB 
5.25 inch floppy disk (and later 
on 3.5 inch), it turned out to be 
huge sales success. 

( 065015 - 1 ) 


Retronics is a monthly column covering vintage electronics including legendary Elektor designs. Contributions, suggestions and requests are welcomed; please send an 
email to editor@elektor-electronics.co.uk, subject: Retronics EE. 


3/2006 - elektor electronics 


77 







SPI BOX 


Next Issue: 


the fast link to a microcontroller! 


Select your own annual subscription and 
receive a free 1 W Luxeon LED Torchlight* 


Available options: 


• Elektor Electronics annual subscription (standard) 

You receive 11 issues, including the July/August double issue. 

• Elektor Electronics annual subscription-PLUS 

You receive 11 issues, including the July/August double issue, 
plus a copy of the Elektor Electronics Volume 2006 CD-ROM 
(normal price £16.25). Your saving: approx. £10.00! 


lektor 


Please fill out the Order Form with this issue. 

Subscription rates and conditions may be found at the back of this issue. 


Ight from 

electronics aac 


This Issue: 


FREE BOOKLET Short Course C for Microcontrollers 


* Offer available to Subscribers who have not held a subscription to Elektor 
Electronics during the last 12 months. Offer subject to availability. 




PUZZLE 


INFOTAINMENT 


Hexadoku 

Puzzle with an electronic touch 


Here is the third Hexadoku puzzle, the brain 
teaser for electronics fans and their family 
members. Solve the puzzle and win one of the 
fantastic prizes! 


The instructions for the puzzle 
are straightforward. In the 
diagram composed of 1 6_1 6 
boxes, enter numbers in such 
a way that all hexadecimal 
numbers 0 through F (that's 0- 
9 and A-F) occur once in 
every row, once in every col- 
umn, and in every one of the 
4_4 boxes (marked by the 
thicker black lines). A number 
of clues are given in the puz- 


zle and these determine the 
start situation. 

Your solution may win a prize 
and requires only the num- 
bers in the grey boxes to be 
sent to us (see below). The 
puzzle is also available as a 
free download from our 
website (Magazine — » 2006 
— > March). 

( 065043 - 1 ) 


Prize winners 

The solution of the January 
2006 Hexadoku is: EA639. 

The E-blocks Starter Kit 
Professional goes to: Ian 
Mowatt (Chester). 


Entering the competition 

Please send the numbers in the grey 
boxes by email, fax or post to 

Elektor Electronics Hexadoku 
Regus Brentford 
1 000 Great West Road 
Brentford TW8 9HH 
United Kingdom. 

Fax (+44) (0)208 2614447 
Email: 

editor@elektor-electronics.co.uk 
Subject: hexadoku 03-2006. 

The closing date is 27 March 2006. 
Competition not open to employees of 
Segment b.v., its business partners 
and/or associated publishing houses. 


An Elektor SHOP 
Voucher worth £35.00 

goes to: M. Devereux (Stock- 
ton on Tees); Paul Ackerman 
(Broughton Ashley); Colin 
Wilkinson (Wareham). 



D 

1 

A 


C 


9 

4 

2 

B 

8 

F 



7 





5 

3 

8 




0 

7 


6 






2 


4 


7 


6 


C 


A 






0 





3 




2 

4 


9 




D 



6 






0 



2 

2 

8 


F 

4 

9 

D 





E 


7 

A 

6 


3 

7 

B 

F 


A 


D 


2 

6 

9 


4 

1 



4 


2 


7 


8 

0 

F 

A 

5 


D 





7 

1 


4 





D 

C 

B 


0 


9 

0 


B 


5 





F 

1 



4 

B 


2 

5 


E 




1 



6 

8 

9 


C 

4 




2 


8 


E 

5 

B 




A 

9 



4 


0 

2 

1 


7 




D 



A 


F 

6 


5 










8 

7 




8 

6 



9 


A 



0 


F 



B 

E 




A 

0 

5 




9 

6 

C 


Solve Hexadoku 
and win! 

Correct solutions qualify for 
an 

E-blocks Starter Kit 
Professional 



worth £248.55 
and three 


Elektor Electronics 
Shop Vouchers 

worth £35 each. 

We believe these prizes 
should encourage all our 
readers to participate! 


3/2006 - elektor electronics 


79 








ELEKTOR 


SHOWCASE 


To book your showcase space contact Huson International Media 


Tel. 


(0) 1 932 564999 

Fax 0044 (0) 1 932 564998 


ALLGOOD TECHNOLOGY 

www.allgoodtechnology.com 

Low-medium volume sub-contract assembly. 
SMT specialist since 1990. Customers include 
military, aerospace etc. 0402 to BGA capabilities, 
automatic assembly and hand built prototypes. 


ATC SEMITEC LTD 

www.atcsemitec.co.uk 

Thermal and current-sensitive components 
for temperature control and circuit protection; 

• NTC Thermistors • Current Diodes 

• Thermostats • Re-settable Fuses 

• Thermal Fuses • Temperature Sensors 

Call today for free samples and pricing 

Tel: 0870 901 0777 Fax: 0870 901 0888 


DESIGN GATEWAY 

www.design-gateway.com 

PalmLogic II .... US$ 399.00 

• Compact Logic Analyzer (L1 1 6mm x W73.3mm x T3mm) 

• High sampling rate (400 MHz/ 8ch, 200 
MHz/1 6ch, 100 MHz/32ch) 

• USB 2.0 high speed mode 

• 8MB memory storage L * 

• Bus Analyzer function 

• Multiple waveform windows 

• Waveform save/restore 

DESIGN GATEWAY 

www.design-gateway.com 

True PCI Starter Kit .... US$135.00 

• PCI Development Kit 

• Based on 200,000 gates FPGA 

• Extension connectors for 72 pin I/O 

• Configuration support for JTAG and slave serial 

• Free PCI Core for Target Mode 




TRUE pet 


DESIGN GATEWAY 

www.design-gateway.com 

Ethernet 10 .... US$115.00 

• 8 bits embedded network microcontroller 

• 6 channels available for 10 bits ADC 

• Ethernet 1 0 BASE T 1 0 Mb &tt 

• UART port RS232/RS485, Max Speed 
atl 1 5200bps 

• 35 bits general purpose I/O 

• 500 bytes user area flash memory 


DESIGN GATEWAY 

www.design-gateway.com 

VariClock... US$163.00 

• Adjustable clock signal synthesizer 

• 3 rotary switches for frequency setting 

• Standard DIP pin arrangement 

• Support both 3V/5V by on-board regulator 

VC250M14P Frequency range : 25-400 MHz 
Frequency setting : 1 MHz step 

VC100M14P Frequency range : 25-100 MHz 

Frequency setting : 1 00 kHz step for 25- 

50 MHz 

: 200 kHz step for more 
than 50 MHz 






£ = 




AVIT RESEARCH 

www.avitresearch.co.uk 

USB has never been so simple... 
with our USB to Microcontroller Interface cable. 
Appears just like a serial port to both PC and 
Microcontroller, for really easy USB connection to 
your projects, or replacement of existing RS232 

interfaces. 

See our webpage for more 
details. Only £29.99 inc vat. 

BETA LAYOUT 

www.pcb-pool.com 

Beta layout Ltd Award- 
winning site in both 
English and German 
offers prototype 

PCBs at a fraction of the cost of the usual 
manufacturer’s prices. 

BURN TECHNOLOGY LTD 

http ://www. b u rntec . co m 

Test & Measurement Equipment 
Distributors 

• Anemometers • Clamp Meters 

• Light Meters • LCR Meters 

• Sound Meters • Multimeters 

• Device Programmers 
Burn Technology Limited, Winfrith Technology 
Centre, Dorchester, Dorset, DT2 8DH 

Tel: (01305) 852090 Fax: (01929) 463214 

COMPUCUT 

http://www.compucutters.com 

Computer Numerical Control from your home PC. 
Great for tricky jobs, and accurate repetitive 
work. We supply: - Software - Interface - Manual 
- Support 

Price £250 plus postage. 

COMPULOGIC LTD 

www.compulogic.co.uk 

Internet Remote Control Starter Kit £139.99 
Create a simple web based remote c 
interface for many applications 

• Miniature Web Server Module 

• Analogue/Digital Module 
•PSU 

• Manuals, software, example HTML 

CONFORD ELECTRONICS 

http://www.confordelec.co.uk 

Lightweight portable battery/mains audio units 
offering the highest technical performance. 
Microphone, Phantom Power and Headphone 
Amplifiers. Balanced/unbalanced signal lines 
with extensive RFI protection. 

DANBURY ELECTRONICS 

http://www.DanburyElectronics.co.uk 

Transformer manufacturers since 1 983. Visit our 
new site! Also link directly to Mike Holme’s Valve/- 
Tube DIY amplifier site, featuring our standard Audio 
Transformers (Mains, Output, Chokes, PP, SE, etc). 






EAGLEPICS 

http://www.eaglepics.co.uk 

Embedded Internet Solutions 

• Stand alone TCP/IP module 

• Platform independent 

• Simple "AT-like" command 

• GPRS or modem connection 

• E-Mail, FTP, HTTP, UDP 

• Development board available 

• Free development utilities 

• Free UDP-only stack 

EASYSYNC 

http://www.easysync.co.uk 

EasySync Ltd sells a wide 
range of single and multi- 
port USB to RS232/RS422 
and RS485 converters at competitive prices. 





ELNEC 

www.elnec.com 

• device programmer 
manufacturer 

• selling through contracted 
distributors all over the world 

• universal and dedicated device programmers 

• excellent support and after sale support 

• free SW updates 

• reliable HW 

• once a months new SW release 

• three years warranty for most programmers 


FUTURE TECHNOLOGY DEVICES 

http://www.ftdichip.com 

FTDI designs and sells 
USB-UART and USB-FIFO 
interface i.c.’s. 

Complete with PC drivers, 
these devices simplify the task of designing or 
upgrading peripherals to USB 



FUTURLEC 

http://www.futurlec.com 

Save up to 60% on 

• Electronic Components 

• Microcontrollers, PIC, Atmel 

• Development Boards, Programmers 
Huge range of products available on-line for 
immediate delivery, at very competitive prices. 



IPEVA LIMITED 

http://www.ipeva.com 

IPEVA sell low cost USB FPGA 
development boards. IPEVA 
provide Design Consultancy 
for Embedded Systems, 

OpenCores-IP, FPGA, ASIC, HDL translation and 
migration. Tel. 0870 080 2340. 



80 


elektor electronics - 3/2006 






products and services directory 


JLB ELECTRONICS 

www.jlbelectronics.com 

Suppliers of electrical / electronic parts and 
consumables. Including: 

• Cable ties / bases 

• Tools / hardware 

• Bootlace ferrules 

• Connectors 

• Solvent sprays & cleaners 

• PVC Tape 

• Heat Sink compound 


KMK TECHNOLOGIES Ltd. 

http://www.kmk.com.hk 

Low Cost DIY Robotic Kits 
and Computer 
Controller Boards. 



LONDON ELECTRONICS COLLEGE 

http://www.lec.org.uk 

Vocational training and education for national 
qualifications in Electronics Engineering and 
Information Technology (BTEC First National, 
Higher National NVQs, GCSEs and Advanced 
Qualifications). Also Technical Management and 
Languages. 


MQP ELECTRONICS 

http://www.mqpelectronics.co.uk 

Leaders in Device 
Programming Solutions. 

• Online shop 

• Low Cost Adapters for all 
Programmers 

• Single Site and Gang Programmers 

• Support for virtually any Programmable Device 



NEW WAVE CONCEPTS 

www.new-wave-concepts.com 

Software for hobbyists: 

• Livewire circuit simulation 
software, only £34.99 

• PCB Wizard circuit design 
software, only £34.99 

Available from all Maplin Electronics stores and 
www.maplin.co.uk. 



OLD COLONY SOUND LAB 

www.audioXpress.com 

Premier source for DIY audio 
for 35 years! 

New catalog features: 

• Books 
•CDs 

•Test & Measurement 

• Kits 

Full range of products and 
magazines for the DIY audio enthusiast! 



PCB WORLD 

http://www.pcbworld.org.uk 

World-class site: Your magazine project or 
prototype PCB from the artwork of your choice 
for less. Call Lee on 07946 846159 for details. 
Prompt service. 


ULTRALEDS iUJ traJ eefe*** 

http://www.ultraleds.co.u!^^^ 

tel: 0871 7110413 

Large range of low cost Ultra bright leds and Led 
related lighting products. Major credit cards 
taken online with same day depatch. 


1 


SHOWCASE YOUR COMPANY HERE 


Elektor Electronics has a feature to help customers 
promote their business, Showcase - a permanent 
feature of the magazine where you will be able to 
showcase your products and services. 

• For just £220 + VAT (£20 per issue for eleven 
issues) Elektor will publish your company name, 
website adress and a 30-word description 


• For £330 + VAT for the year (£30 per issue 
for eleven issues) we will publish the above plus 
run a 3cm deep full colour image - e.g. a product 
shot, a screen shot from your site, a company 
logo - your choice 

Places are limited and spaces will go on a strictly 
first come, first served basis. So please fax back 
your order today! 


I wish to promote my company, please book my space: 

• Text insertion only for £220 + VAT • Text and photo for £330 + VAT 


NAME: ORGANISATION: 

JOB TITLE: 

ADDRESS: 


.TEL: 


PLEASE COMPLETE COUPON BELOW AND FAX BACK TO 00-44-(0)1932 564998 

COMPANY NAME 

WEB ADDRESS 

30- WORD DESCRIPTION 



QUASAR ELECTRONICS 

www.QuasarElectronics.com 

Over 300 electronic kits, 
projects and ready built 
units for hobby, education 
and industrial applications 
including PIC/ATMEL 
programming solutions. Online ordering facilities. 
Tel: +44 (0) 870 246 1826 
Fax: +44 (0) 870 460 1 045 
Email: sales@QuasarElectronics.com 


QUASAR 

ttlaelrtiftici 


ROBOT ELECTRONICS 

http://www.robot-electronics.c o.uk 

• Ultrasonic rangefinders 

• Motor H-Bridge controllers 

• Magnetic Compasses 

• RC servos and controllers 

• PIC programmers and components 

• Electronic Design/Development and 
Manufacturer to industry 




SK PANG ELECTRONICS 

http://www.skpang.co.uk 

• ELM OBDII 1C 

• VAG-COM Interface 

• OBDII connector and cable 

• Modtronix Micro X board 

• Embedded Ethernet Controller 

• PIC Microcontroller, CAN Bus driver 
Major credit cards taken online. 

SYTRONIC TECHNOLOGY LTD 

www.m2mtelemetry.com 

Supplier of wireless modules and accessories for 
remote 

monitoring M2M applications. 

•GSM/GPRS TCP/IP modules 

• Embedded GSM/GPRS modem 

• Development Kits 

• GPS modules ± . 

• GSM/GPS antennas 1 

• Adapter cables 
Online ordering facilities. 

Tel (01 394) 210911 



USB INSTRUMENTS 

http://www.usb-instruments.com 

USB Instruments specialises 
in PC based instrumentation 
products and software such 
as Oscilloscopes, Data 
Loggers, Logic Analaysers 
which interface to your PC via USB. 



VIRTINS TECHNOLOGY 

www.virtins.com 

PC and Pocket PC based 
virtual instrument for 
electronics enthusiasts, 
students, professionals and 
scientists, including sound 
card real time oscilloscope, 
spectrum analyzer, and signal generator. Free to 
download and try. 



ELECTRONIC ENTHUSIASTS 

Only one magazine tests its projects and circuits in its own lab before publication 


ELEKTOR ELECTRONICS 
THE ELECTRONICS & 
COMPUTER MAGAZINE 




Contact: Worldwide Subscription Service Ltd, 

Unit 4 Gibbs Reed Farm, Pashley Road, Ticehurst TIMS 7HE 
Telephone: 01580 200657 Fax: 01580 200616 www.elektor-electronics.co.uk 


3/2006 - elektor electronics 


81 









lektor 





Order o 
www.elektor-el 


Order now using the Order Form in 
the Readers Services section in this issue. 


CD-ROM 


ECD 

Edition 3 

Elektor’s Components 
Database gives you easy 
access to design data for 
over 5,000 ICs, more than 
35,000 transistors, FETs, 
thyristors and triacs, just 
under 25,000 diodes and 
1 ,800 optocouplers. 

All databank applications are 

fully interactive, allowing the user to add, 

edit and complete component data. 

£14.95 (US$ 26.50) 

Audio Collection 2 

A unique CD-ROM for the 
true audio lover, containing 
no fewer than 75 audio 
designs from the past five 
year volumes of Elektor 
Electronics magazine. 

The articles on the CD-ROM 
cover test & measurement 
equipment, amplifiers, digital 
audio and loudspeaker technology. Highlights 
include the Crescendo Millennium Edition, 
Audio-DAC 2000, Audio-ADC 2000 and the 
I R-S/PDIF Transmitter and Receiver. Using the 
included Acrobat Reader you are able to browse 
the articles on your computer, as well as print 
texts, circuit diagrams and PCB layouts. 

£12.05 (US$ 21.25) 

Robotics 

A large collection of data- 
sheets, software tools, tips, 
tricks and Internet links to 
assorted robot constructions 
and general technical infor- 
mation. All aspects of modern 
robotics are covered, from 
sensors to motors, mechanical 
parts to microcontrollers, not forgetting 
matching programming tools and 
libraries for signal processing. 

£12.05 (US$ 21.25) 


More information on www.elektor-electronics.co.uk 




Faultfinding in Computers 
and Digital Circuits 

This book covers faultfinding not just in micro- 
processor systems, microcontrollers and indus- 
trial PCs, but also in consumer items such as 
personal computers, multimedia devices, digital 
television and so on. The knowledge and techni- 
cal skills needed to put such equipment into 
service, and to maintain it in good working order, 
go beyond the level of simple self-help tips and 
basic measurements. The object of this book is to 
help the reader to acquire this knowledge and 
understanding. 

Dictionary 

of Monitor Technology 

The Dictionary of Monitor Technology is a 
pioneering book of unsurpassed range which 
clearly documents all aspects of the develop- 
ment of computer monitors. The subjects 
covered extend from the first 12-inch IBM 
monitor to today’s high-tech units. This book is 
a mine of practical information and is required 
reading for all computer users with an interest 
in technology, successful hardware sales staff 
and repair engineers. 


fbiflffijfdfria rri 
Compurert and 
■ ift U I f E 

\ 


Signal 



ISBN 0-905705-60-2 
625 pages 

£31.15 (US$ 63.00) 


iliT' > rMPf 9 w * 

Tto+EJifiPS* 



a 


ISBN 0-905705-64-5 
265 pages 

£25.95 (US$ 52.00) 








BESTSELLING BOOKS 


Top-5 

Microcontroller 
Basics 

ISBN 0-905705-67-X £18.70 (US$ 33.70) 

PC-1 nterf aces 
under Windows 

ISBN 0-905705-65-3 £25.95 (US$ 22.90) 

Modern High-end Valve Amplifiers 

ISBN 0-905705-63-7 £25.95 (US$ 52.00) 

308 Circuits 

ISBN 0-905705-66-1 £18.20 (US$ 37.00) 

Dictionary of Monitor Technolgy 

ISBN 0-905705-64-5 £25.95 (US$ 52.00) 



More information on www.elektor-electronics.co.uk 







nline at 

ectronics.co.uk 

Due to practical constraints, final illustrations and specifications 
may differ from published designs. Prices subject to change. 
See www.elektor-electronics.co.uk for up to date information. 


R8C/1 3 


Application Board for 

(March 2006) 

Extends R8C/13 micro module 
with 2 x serial I/O. USB, LCD, 
LEDs, analogue I/P, PSU and, 
reset and MODE control. 

Ready built PCB 

050179-92 

£ 48.27 / $ 90.94 
LCD with backlight 

030451-72 

£7.25/$ 13.65 



Poly-LED display 

030451-73 

£ 25.50 / $ 48.05 


Elektor Electronics (Publishing) 

Regus Brentford 

1000 Great West Road 

Brentford TW8 9HH 

United Kingdom 

Tel.: +44 (0) 208 261 4509 

Fax: +44 (0) 208 261 4447 

Email: sales@elektor-electronics.co.uk 

Kits & Modules 


Versatile FPGA Module 

(March 2006) 

Ready-assembled FPGA module 
with Altera Cyclone FPGA; 
including programming interface, 
programming cables and 
connectors. 

040477-91 

Subscribers: Non-subscribers: 

£ 1 71 .80 / $ 323.50 £ 206.30 / $ 388.50 

(incl. all 8 Elektor course issues) 



A 16-bit Tom Thumb 

(February 2006) 

R8C Starter Kit com- 
prising CD-ROM and 
R8C/13 microcon- 
troller board with SIL mm 
pinheaders supplied 
separately. 

050179-91 

£8.30/$ 15.60 



OBD-2 Analyser 

(July/August 2005) 

Kit of parts including PCB, programmed controller, compo- 
nents (including IC7 ; IC3 = PCA82C250, 

12 V), enclosure and RS232 cable. 

OBD cable not included. 

050092-71 

£52 .50/ $96.95 
OBD cable 

050092-72 

£27.55/ $51 .95 



Further products from Elektor Electronics: 


READY-BUILT PROJECTS £ $ 


ClariTy 300-W Class-T Amplifier 

030217-91 Amplifier board with SMDs pre-fitted; cores for LI & L2 34-50 55.70 

Flash Microcontroller Starter Kit 

010208-91 ready-assembled PCB incl. software, cable, adapter & related articles 69-00 112.50 

Gameboy Digital Sampling Oscilloscope (GBDSO) 

990082-91 ready-assembled board, incl. the PC software and related articles 103-00 183.00 

Micro Webserver with MSC1210 Board 


030060-91 Microprocessor Board, ready-assembled 

044026-91 Network Extension Board, ready-assembled 

044026-92 Combined package (030060-91 & 044026-91 & related articles) 

LPC210x ARMee Development System 

040444-91 Processor board, ready-made and tested 

75-90 

44-50 

117-50 

25-50 

142.95 
83.95 

220.95 

48.05 

NO. 352 MARCH 2006 

Application Board for R8C/13 



050179-92 Ready-assembled board 

48-27 

90.94 

050179-1 PCB 

13-77 

25.94 

030451-72 LCD with backlight 

7.25 

13.65 

030451-73 Poly-LED display 

25.50 

48.05 


FPGA-Protoyping board 

050370-91 Ready aseembled board 

Telephone Eavesdropper 

030379-1 PCB 9.05 17.05 


NO. 350 JANUARY 2006 

95-watt Laptop PSU Adaptor 



050029-1 PCB 

4-80 

9.05 

Automatic Attic Window Controller 



0501 39-1 1 Disk, PIC source & hex code 

5-20 

9.75 

050139-41 PIC16F84A-20I/P, programmed 

13-10 

24.65 

030451-72 LCD Modue 2x16 characters 

7-25 

13.65 

030451-73 PLED Module 2x16 characters 

25-50 

48.05 

SMD Reflow Soldering Oven 



05031 9-1 1 Disk, source and hex code 

5-20 

9.75 

050319-41 AT89C52/24JI, programmed 

7-60 

14.25 

030451-72 LCD Modue 2x16 characters 

7-25 

13.65 

030451-73 PLED Module 2x16 characters 

25-50 

48.05 

Timer Switch for Washing Machine 



050058-1 PCB 

8-90 

16.70 

050058-1 1 Disk, PIC source & hex code 

5-20 

9.75 

050058-41 PIC16F84, programmed 

13-10 

24.65 

NO. 349 DECEMBER 2005 

From A to D via USB 



050222-1 PCB 

7-95 

14.95 

050222-41 IOW24-P, programmed 

9-40 

17.75 

Telephone Supervisor 



050039-41 PIC1 6F628-20/P, programmed 

8-20 

15.55 

050039-81 CD-ROM, PIC hex & source codes, LCM First Server 

6-90 

12.95 

NO. 348 NOVEMBER 2005 


Versatile FPGA Module 

040477-91 Ready aseembled plug-on module 
For subscribers 


171.80 323.50 


Remote Control by Mobile Phone 

040415-1 PCB 

04041 5-1 1 Disk, PIC source & hex files 


6-20 

5-20 


11.65 

9.75 


















INFO & MARKET 


SNEAK PREVIEW 



SPI Box 

Many of today's microcontrollers and associated peripheral ICs sport a Ser- 
ial Peripheral Interface (SPI) connection for programming and control pur- 
poses. The SPI is a relatively simple add-on and requires little hardware 
to drive from a PC. Usually, an RS232 port is 'misused' for the purpose 
but admittedly that's fraught with a few disadvantages. The programmer 
we've in mind goes round these problems while also ensuring short pro- 
gramming times even if a USB/serial adapter is being used for lack of an 
RS232 port on the PC or laptop. 


Theme Plan for 2006 


January Recycling / Reverse Engineering 

February Motors / Propulsion 

March Development/ Microcontrollers 

April Power Supplies / Safety 

May Soldering / Etching 

June Satellites 

July/ August . . . .Summer Circuits 

September Esoterics / Test & Measurement 

October e-Simulation 

November Chipcards / Protection 

December Electromechanical / Enclosures 


The Electronic Laundry 

Microcontrollers are applied in massive numbers in all sorts of consumer-market electrical equipment. Large manufacturers spend 
lots of timer and money on hardware and software development for a specific product. Eventually, units have to be mass-pro- 
duced by the millions so design errors and bugs are out of the question. We paid a visit to of washing machine giant Miele for a 
peek in their hard- and software development department. 


Mains Adapters Undressed 

Switch-mode versions of the trusty mains adapter (or 'battery eliminator') are 
increasingly seen with mobile equipment like PDAs, phones and MP3 players. The 
Also... newer versions no longer have bulky, energy wasting mains transformers and lin- 

Electric Fence; AA Cell Characteriser; ear regulators. We took a few of these newcomers apart to examine their construc- 

FPGA Applications (1 ); E-blocks; tion and operation. The experience so gained is put into practice by the home con- 

Hexadoku Puzzle. struction of a DC-DC converter. 



RESERVE YOUR COPY NOW! The April 2006 issue goes on sale on Thursday 16 March 2006 (UK distribution only). 

UK subscribers will receive tbe magazine a few days before this date. Article titles and magazine contents subject to change. 


NEWSAGENTS ORDER FORM 

SHOP SAVE / HOME DELIVERY 

Please save / deliver one copy of Elektor Electronics magazine for me each month 

Name: 

Address: 

Post code: 

Telephone: 

Date: 

Signature: 


lektor 

lectronics 

lea-ding the w a y 

Please cut out or photocopy this form, com- 
plete details and hand to your newsagent. 
Elektor Electronics is published on the third 
Friday of each month, except in July. 
Distribution S.O.R. by Seymour (NS). 



www.elektor-electronics.co.uk www.elektor-electronics.co.uk www.elektor-electronics 


Elektor Electronics 


aa 


the web 


All magazine articles back to volume 2000 are available online in pdf format. The article summary and parts list (if applicable) can 
be instantly viewed to help you positively identify an article. Article related items are also shown, including software downloads, cir- 
cuit boards, programmed ICs and corrections and updates if applicable. 

Complete magazine issues may also be downloaded. 

In the Elektor Electronics Shop you'll find all other products sold by the pub- 
lishers, like CD-ROMs, kits and books. A powerful search function allows you 
to search for items and references across the entire website. 

Also on the Elektor Electronics website: 

• Electronics news and Elektor announcements 

• Readers Forum, 

• PCB, software and e-magazine downloads 

• Surveys and polls 

• FAQ, Author Guidelines and Contact 



ijmrnt -h K+- — »— n 




JUIMB 


fe ■ hkltrn 

H 


5 


84 


elektor electronics - 3/2006 











Please supply the following. For PCBs, front panel foils, EPROMs, PALs, GALs, microcontrollers and diskettes, state the part number and 
description; for books, state the full title; for photocopies of articles, state full name of article and month and year of publication. 
PLEASE USE BLOCK CAPITALS. 


Description 


Price each Qty. Total Order Code 


CD-ROM CD-ROM Elektor 2005 i 

[TJ323 

[ £ 16.25 

CD-ROM Home Automation 1 

[333 

[ £ 12.95 


CD-ROM ECD Edition 3 
Microcontroller Basics 
Flash Microcontroller Starter Kit 
E-blocks Starter Kit basic 
E-blocks Starter Kit professional 
E-blocks Easy Internet Kit 
E-blocks Easy CAN Kit 


£ 14.95 
£ 18.70 
£ 69.00 
£ 96.00 
£ 166.00 
£ 232.50 
£ 299.00 


METHOD OF PAYMENT 

(see reverse before ticking as appropriate) 


□ 

□ 

□ 

□ 


Bank transfer 
Cheque 

(UK-resident customers ONLY) 

Giro transfer 




Expiry date: 

Verification code: 

SWITCH ONLY: 
Start date: 


Prices and item descriptions subject to change. 

The publishers reserve the right to change prices 
without prior notification. Prices and item descriptions 
shown here supersede those in previous issues. E. & O.E. 


Sub-total 
P&P 
Total paid 


Name 


Address + Post code 


Issue number: 


Please send this order form to * 

(see reverse for conditions) 

Elektor Electronics (Publishing) 

Regus Brentford 
1000 Great West Road 
Brentford TW8 9HH 
United Kingdom 

Tel.: (+44) (0) 208 261 4509 
Fax: (+44) (0) 208 261 4447 
Internet: www.elektor-electronics.co.uk 
sales@elektor-electronics.co.uk 


Tel. 


Email 



Date - - 2006 Signature 


EL03 



Yes, I am taking out an annual subscription 
to elektor electronics and receive a free 
1 W Luxeon LED Torchlight. 


I would like: 

Standard Subscription (11 issues) 
Subscription-Plus 

(11 issues plus the Elektor Volume 2006 CD-ROM) 


* Offer available to Subscribers who have not held a subscription 
to Elektor Electronics during the last 12 months. Offer subject to availability. 
See reverse for rates and conditions. 


Name 


Address + Post code 


Tel. 


Email 



-Q 

CO 


Date 

* cross out what is not applicable 
EL03 


- 2006 Signature 


*USA and Canada residents may 

(but are not obliged to) 

use $ prices, and send the order form to: 

Old Colony Sound Lab 
P.O. Box 876, Peterborough 
NH 03458-0876. Tel. (603) 924-6371, 924-6526, 
Fax: (603) 924-9467 
Email: custserv@audioXpress.com 



METHOD OF PAYMENT 

(see reverse before ticking as appropriate) 

Bank transfer 
Cheque 


(UK-resident customers ONLY) 

Giro transfer 



Expiry date: 

Verification code: 

SWITCH ONLY: 
Start date: 

Issue number: .... 


Please send this order form to 

Elektor Electronics (Publishing) 

Regus Brentford 
1000 Great West Road 
Brentford TW8 9HH 
United Kingdom 

Tel.: (+44) (0) 208 261 4509 
Fax: (+44) (0) 208 261 4447 
Internet: www.elektor-electronics.co.uk 
subscriptions@elektor-electronics.co.uk 







ORDERING INSTRUCTIONS, P&P CHARGES 


Except in the USA and Canada, all orders, except for subscriptions (for which see below), must be sent BY POST or FAX to our Brentford address 
using the Order Form overleaf. On-line ordering: http://www.elektor-electronics.co.uk 

Readers in the USA and Canada may (but are not obliged to) send orders, except for subscriptions (for which see below), 

to the USA address given on the order form. Please apply to Old Colony Sound for applicable P&P charges. Please allow 4-6 weeks for delivery. 

Orders placed on our Brentford office must include P&P charges (Priority or Standard) as follows: 

UK: £4.00 Europe: £5.00 (Standard) or £7.00 (Priority) Outside Europe: £8.00 (Standard) or £12.00 (Priority) 

HOWTO PAY 


All orders must be accompanied by the full payment, including postage and packing charges as stated above or advised by Customer Services staff. 

Bank transfer into account no. 40209520 held by Elektor Electronics (Publishing) / Segment b.v. with ABN-AMRO Bank, London. IBAN: GB35 
ABNA 4050 3040 2095 20. BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name and address gets communicated to us. 
Cheque sent by post, made payable to Elektor Electronics (Publishing) / Segment b.v.. We can only accept sterling cheques and bank drafts 
from UK-resident customers or subscribers. We regret that no cheques can be accepted from customers or subscribers in any other country. 

Giro transfer into account no. 34-152-3801, held by Elektor Electronics (Publishing) / Segment b.v. Please do not send giro transfer/deposit 
forms directly to us, but instead use the National Giro postage paid envelope and send it to your National Giro Centre. 

Credit card VISA, Access, MasterCard, JCBCard and Switch cards can be processed by mail, email, web, fax and telephone. Online ordering 
through our website is SSL-protected for your security. 

COMPONENTS 


Components for projects appearing in Elektor Electronics are usually available from certain advertisers in this magazine. If difficulties in the supply 
of components are envisaged, a source will normally be advised in the article. Note, however, that the source(s) given is (are) not exclusive. 

TERMS OF BUSINESS 


Delivery Although every effort will be made to dispatch your order within 2-3 weeks from receipt of your instructions, we can not guarantee this 
time scale for all orders. Returns Faulty goods or goods sent in error may be returned for replacement or refund, but not before obtaining our 
consent. All goods returned should be packed securely in a padded bag or box, enclosing a covering letter stating the dispatch note number. If the 
goods are returned because of a mistake on our part, we will refund the return postage. Damaged goods Claims for damaged goods must be 
received at our Brentford office within 10-days (UK); 14-days (Europe) or 21 -days (all other countries). Cancelled orders All cancelled orders 
will be subject to a 10% handling charge with a minimum charge of £5-00. Patents Patent protection may exist in respect of circuits, devices, 
components, and so on, described in our books and magazines. Elektor Electronics (Publishing) does not accept responsibility or liability for failing 
to identify such patent or other protection. Copyright All drawings, photographs, articles, printed circuit boards, programmed integrated circuits, 
diskettes and software carriers published in our books and magazines (other than in third-party advertisements) are copyright and may not be 
reproduced or transmitted in any form or by any means, including photocopying and recording, in whole or in part, without the prior permission 
of Elektor Electronics (Publishing) in writing. Such written permission must also be obtained before any part of these publications is stored in 
a retrieval system of any nature. Notwithstanding the above, printed-circuit boards may be produced for private and personal use without prior 
permission. Limitation of liability Elektor Electronics (Publishing) shall not be liable in contract, tort, or otherwise, for any loss or damage suffered 
by the purchaser whatsoever or howsoever arising out of, or in connexion with, the supply of goods or services by Elektor Electronics (Publishing) other 
than to supply goods as described or, at the option of Elektor Electronics (Publishing), to refund the purchaser any money paid in respect of the goods. 
Law Any question relating to the supply of goods and services by Elektor Electronics (Publishing) shall be determined in all respects by the laws 
Of England. January 2006 


SUBSCRIPTION RATES FOR ANNUAL 
SUBSCRIPTION 



Standard 

Plus 

United Kingdom 

£41 .90 

£48.80 

Surface Mail 



Rest of the World 

£54.50 

£61.40 

USA & Canada 

US$ 95.50 

US$106.50 

Airmail 



Rest of the World 

£68.90 

£75.80 

USA & Canada 

US$120.00 

US$131.00 


HOWTO PAY 


Bank transfer into account no. 40209520 held by Elektor Electronics 
(Publishing) / Segment b.v. with ABN-AMRO Bank, London. IBAN: GB35 
ABNA 4050 3040 2095 20. BIC: ABNAGB2L. Currency: sterling (UKP). 
Please ensure your full name and address gets communicated to us. 

Cheque sent by post, made payable to Elektor Electronics (Publishing) 
/ Segment b.v.. We can only accept sterling cheques and bank drafts 
from UK-resident customers or subscribers. We regret that no cheques 
can be accepted from customers or subscribers in any other country. 

Giro transfer into account no. 34-152-3801, held by Elektor 
Electronics (Publishing) / Segment b.v. Please do not send giro transfer/ 
deposit forms directly to us, but instead use the National Giro postage 
paid envelope and send it to your National Giro Centre. 

Credit card VISA, Access, MasterCard, JCBCard and Switch cards can 
be processed by mail, email, web, fax and telephone. Online ordering 
through our website is SSL-protected for your security. 


SUBSCRIPTION CONDITIONS 


The standard subscription order period is twelve months. If a perma- 
nent change of address during the subscription period means that 
copies have to be despatched by a more expensive service, no extra 
charge will be made. Conversely, no refund will be made, nor expiry 
date extended, if a change of address allows the use of a cheaper 
service. 

Student applications, which qualify for a 20% (twenty per cent) reduc- 
tion in current rates, must be supported by evidence of studentship 
signed by the head of the college, school or university faculty. A 
standard Student Subscription costs £33.50, a Student Subscription- 
Plus costs £40.40 (UK only). 

Please note that new subscriptions take about four weeks from receipt 
of order to become effective. 

Cancelled subscriptions will be subject to a charge of 25% (twenty- 
five per cent) of the full subscription price or £7.50, whichever is the 
higher, plus the cost of any issues already dispatched. Subsciptions 
cannot be cancelled after they have run for six months or more. 

January 2006 



<D 



lectronics 


Home Automation 

This CD-ROM provides an overview of 
what manufacturers offer today in the field 
of Home Networking, both wired and wireless. 


The CD-ROM contains specifications, standards 

and protocols of commercially available bus and network systems. 

For developers, there are datasheets of specific components and 
various items with application data. End-users and hobbyists will find 
ready-made applications that can be used immediately. 

The documents included on the CD-ROM have been classified 
according to communication media: mains (power line), coaxial cable, 
telephone line and wireless (RF). 



Index of Advertisers 


Allgood Technology, Showcase www.allgoodtechnology.com 

ATC Semitec Ltd, Showcase www.atcsemitec.co.uk .... 

Audioxpress, Showcase www.audioxpress.com .... 

Avit Research, Showcase www.avitresearch.co.uk . . . 


.80 

.80 

.81 

.80 


Beta Layout, Showcase www.pcb-pool.com 45, 80 

Bitscope Designs www.bitscope.com 15 

Breadboarding Systems www.breadboarding.co.uk 11 

Burn Technology LTD, Showcase www.burntec.com 80 

Compucut, Showcase www.compucutters.com 80 

Compulogic, Showcase www.compulogic.co.uk 80 

Conford Electronics, Showcase www.confordelec.co.uk 80 

Cricklewood www.cricklewoodelectronics.com 45 


Danbury, Showcase www.DanburyEiectronics.co.uk 

Design Gateway, Showcase www.design-gateway.com . . . 

Eaglepics, Showcase www.eaglepics.co.uk 


.80 

.80 

.80 


Easysync, Showcase www.easysync.co.uk 7, 80 

Elnec, Showcase www.elnec.com 80 

Eurocircuits www.thepcbshop.com 33 

Future Technology Devices, Showcase . . .www.ftdichip.com 3, 80 

Futurlec, Showcase www.futurlec.com 80 

Flitex www.hitex.co.uk 27 

Ipeva Limited, Showcase www.ipeva.com 80 

Jaycar Electronics www.jaycarelectronics.co.uk 2 

JLB Electronics, Showcase www.jibeiectronics.com 81 


KMK Technologies Ltd, Showcase . . . 

Labcenter 

Lichfield Electronics 

London Electronics College, Showcase 

MQP Electronics, Showcase 

New Wave Concepts, Showcase 

Newbury Electronics 

Number One Systems 

Nurve Networks 

PCB World, Showcase 

Pico 

Quasar Electronics, Showcase 

Robot Electronics, Showcase 

Showcase 

SK Pang Electronics, Showcase 

Sytronic Technology, Showcase 

Ultraleds, Showcase 

USB Instruments, Showcase 

Virtins Technology, Showcase 


.www.kmk.com.hk 81 

.www.iabcenter.co.uk 88 

.www.lichfieldelectronics. co.uk 33 

.www.lec.org.uk 81 

. www. mgpelectronics. co.uk 81 

.www.new-wave-concepts.com 81 

. www. ne wburyelectronics. co.uk 33 

.www.numberone.com 45 

.www.xgamestation.com 33 

. www. pcb world, org. uk 81 

.www.picotech.com 27 

.www.guasarelectronics.com 26, 81 

. www. robot-electronics, co.uk 81 

80, 81 

.www.skpang.co.uk 81 

. www. m2mtelemetry. com 81 

.www.uitraieds.co.uk 81 

.www.usb-instruments.com 81 

.www.virtins.com 81 


Advertising space for the issue of 11 April 2006 
may be reserved not later than 14 March 2006 

with Fluson International Media - Cambridge House - Gogmore Lane - 
Chertsey, Surrey KT 1 6 9AP - England - Telephone 01 932 564 999 - 
Fax 01 932 564998 - e-mail: aerrvb@husonmedia.com to whom all 
correspondence, copy instructions and artwork should be addressed. 


3/2006 - elektor electronics 


87 







Schematic & 
PCB Layout 


JLU ! JL J ■ a 1 • I 


E i Mm 

Schematic 


i 

f jf 

i V 1 


■ 1 u I 1,1 ■! .1 » * i, m i jf 


CFU 

Wodeff 


Auto 
Routing 
naMptufufti 


^ Virtual System Modelling 

New Features 
£-4 in Version 6.8 

Interactive Design Rule Check, 
Mitring / Unmitring. 

Enhanced track editing. 


The Complete Electronics Design System 


Powerful & flexible schematic capture. 

Auto-component placement and rip-up/retry PCB routing. 
Polygonal gridless ground planes. 

Libraries of over 8000 schematic and 1000 PCB parts. 

Bill of materials, DRC reports and much more. 


Mixed Mode SPICE Circuit Simulation 


• Struct/Array expansion. 

• ELF/DWARF file loader. 


• Berkeley SPICE3F5 simulator with custom extensions for 
true mixed mode and interactive simulation. 

• 6 virtual instruments and 14 graph based analysis types. 

• 6000 models including TTL, CMOS and PLD digital parts. 

• Fully compatible with manufacturers’ SPICE models. 


• Expanded model libraries. 

Call Now for Upgrade Pricing 


Proteus VSM - Co-simulation and debugging for popular Micro-controllers 



Supports PIC, AVR, 8051, ARM7 and BASIC STAMP micro-controllers. 
Co-simulate target firmware with your hardware design. 

Includes interactive peripheral models for LED and LCD displays, 
switches, keypads, virtual terminal and much, much more. 

Compatible with popular compilers and assemblers from Microchip, 
Crownhill, IAR, Keil, and others. 


Electronics 

53-55 Main Street, Grassington. BD23 5AA 


Tel: 01756 753440 
Fax: 01756 752857 

Contact us for 

Free Demo CD 




ARM/LPC2000 



MODELS FOR 
PROTEUS VSM 

NOW AVAILABLE 




www.labcenter.co.uk 

info@labcenter.co.uk 










DO 


'<1 



t 


sot up race 


reinhardt weber 


p*CQ ■ If 
trail 3 = 1 j 
oal 5 ■ If 
canOS = Oj 

eml& m Of 
™i 1 s 0; 
cmdfi *> Of 

&&&{”&&$*} 

□ s ^ ( " nop " } j 

ae*( "flop") f 
Mmpnop") j 
ocd2 = Of 
preG “ Of 
pd 1 — OeOF j 


t-Dgglo_ladB( ) 

{ 

while ( 1 } 

t 

pl a QeGO? 


r-T 





r 


eel 

ran 

ics 


/* Protect 
/■ tin Sou 
/* ICIH- 
/ * if in d 
/■ Kaia cl 








/* OU6 ilHdi 

/* Hrtlti 

/ * AEBSMCblO 






/" Ka io clock 
/* Proto cl on * 
/* Sat Port 1, 





ISBN 90-5381-159-1 
£1 4.95 (US$ 26.50) 


Elektor’s Components 
Database gives you easy 
access to design data for 
over 5,000 ICs, more than 


35,000 transistors, FETs, 
thyristors and triacs, just 
under 25,000 diodes and 


Elektor Electronics 
(Publishing) 

Regus Brentford 


1 ,800 optocouplers. 

All databank applications 
are fully interactive, allowing 


1000 Great West Road 
Brentford TW8 9HH 
United Kingdom 


the user to add, edit and 


Tel. +44 (0) 208 261 4509 


complete component data. 


Fax +44 (0) 208 261 4447 


More information on www.elektor-electronics.co.uk 




Contents 


Foreword 

Why C? 4 

C Basics 

The structure of a C program 6 

The main function 6 

Comments in C 6 

The #include directive 7 

Keywords in C 7 

Constants and Variables 

Number systems 8 

Data types 8 

Constants 9 

Variables 9 

Operators in C 

Arithmetic operators 1 1 

Relational operators 11 

Logical operators 1 1 

Shortcuts 12 

Functions in C 

The function concept 13 

Declaring a function 13 

Calling a function 14 

Program Control 

If 16 

if... else 16 

switch 17 

for 18 

while 19 

do. ..while 20 

Appendix 

Header file sfr_r81 3. h 21 

Header file math.h 23 


elektor electronics 


3 



Foreword 

Why C? 

Many electronics hobbyists have used microcontrollers successfully, and they have 
also written wonderful programs in assembly language. As the size and complexity of 
an assembly-language program increase, the desire for a more effective 
programming environment also increases. Anyone who has tried to implement a 
mathematical function in assembly language, such as 1/x, sin(x) or the like, knows 
the problems. Here a high-level language such as C, which is the industry standard 
in the microcontroller and microprocessor world, offers decisive advantages. C 
programs are portable, which means the program structure can be transferred to 
other types of microcontrollers after it has been written. The only things that have to 
be modified are the port assignments and the settings for the special function 
registers. 

Professional programmers claim that an assembly-language program that would take 
14 days to generate can be generated in 2 to 3 days in C. What’s more, an 
increasing number of semiconductor manufacturers are making highly effective 
development environments available at no charge. That’s another good reason to 
start using C. 

But there’s a hitch. As we all know, the gods have ordained that success doesn’t 
come without hard work. An introductory course in the C language and sample 
programs from technical magazines can help you overcome the initial hurdles, but 
will take a while before you can write you own programs. You will also have to master 
a certain amount of specialist vocabulary. As can be seen from contributions to 
microcontroller forums and questions asked in these forums, that forms a significant 
problem for many electronics hobbyists. 

This booklet is limited to the basic elements of the C language. We have intentionally 
omitted complex C structures such as pointers, arrays, strings, structures, unions and 
the like. This booklet is intended to serve as a reference for beginners. It cannot 
replace a basic course in C, nor is it intended to do so. 


4 


elektor electronics 



C Basics 

The structure of a C program 

All C programs consist of several parts, such as comments, preprocessor 
instructions, declarations, definitions, expressions, assignments and functions. The 
following listing shows a simple example. 


/* FILE :my1c.c */ 

/* DATE :Wed, Nov 23 2005 

/* DESCRIPTION Program toggles leds on port_1 
/* CPU TYPE :R8C 7 


include "sfr r813.h" 


compiler directive 


long t; 

setup_r8c() 

{ 

prcO = 1 ; 
cm13 = 1; 
cm15 = 1; 
cm05 = 0; 
cm16 = 0; 
cm17 = 0; 
cm06 = 0; 
asm("nop"); 
asm("nop"); 
asm("nop"); 
asm("nop"); 
ocd2 = 0; 


variable 

declaration 





function 1 

/* Protect ox'C * / 

/* Xin Xout 7 

/* XCIN-XCOUT drive capacity: HIGH 7 
/* Xin on 7 

/* Main clock = No Division mode 7 

/* CM 16 and CM17 enable 7 
/* Waiting for stable oscillation 7 
/* Assembly-language code 


, . . assembly-language code 



pi = 0x0F; 
for (t=0; t<1 50000; t++); 


value 

asskmment 


void main 


main function 



{ 

} 


setup_r8c(); 

toggle_leds(); 



elektor electronics 


5 



The main function 


Every C program must include at least one function, which is called the main 
function. This is the primary function in a C program, and it is always the first function 
to be called when the program is run. It’s considered good programming style to have 
the main routine consist primarily or entirely of function calls, instead of containing 
the entire code of the program. That makes the program a lot easier to understand 
and maintain, and it allows the programming effort to be divided among several 
programmers for large projects. The main function is declared in the same manner 
as any other function. 


void main(void) 

{ 

/* Your program 

block j'' 

main() 

/* Your program 

markers 1 

code goes here 7 l 

code goes here 7 

} 




All instructions and functions belonging to main are enclosed in curly brackets 
{...}. This is called ‘block building’. In the above example, void means ‘empty’ 
and indicates that the main function does not require any input parameters and 
does not return any result after the instructions are executed. The two instances of 
the void keyword can also be omitted if desired. 

Comments in C 

All text strings and phrases that don’t form part of the actual program are called 
‘comments’. Comments are ignored by the compiler, which means they do not 
occupy any space in memory. However, they are quite valuable for explaining the 
program (or important parts of the program) to other people. And of course, they’re 
very useful for the author of the program as well. In many cases, you may not 
remember why you wrote the code in a particular manner when you look at your 
program several days later. And no matter how appropriate the saying ‘lean is 
keen’ may be in other contexts, it certainly doesn’t apply to computer programs. 


/* // This is a single-line comment. 

Comments are 

enclosed between 

diagonal slashes 

and asterisks. 7 


Single-line comments begin with two diagonal slashes and end automatically at 
the end of the line. 

A semicolon ( ; ) is usually used to designate a comment in assembly-language 
programming, but in the C language it marks the end of an instruction. 


6 


elektor electronics 







#include 


There are many declarations and functions that are not included in the ANSI 
standard for the C language, even though they may be necessary or very useful. 
They are commonly ‘hidden’ in libraries. You have to tell the compiler to include 
these library files, which are called ‘header files’, so it can use these declarations 
and functions when it compiles your C source code. You can recognise header 
files by the .h file extension. 

Examples: 


#include "stdio.h" 


Used in C programs intended to be run on a PC. 

[Standard input/output; includes the print function printf() .] 


include "sfr_r813.h" 

The Renesas library. The names and bits of the registers of the R8C 
microcontroller, such as pi , pdl , p1_7 etc., are defined here. 


Keywords in C 

A total of 32 terms known as ‘keywords’ are defined in the ANSI standard for the C 
language. These keywords are reserved for the compiler. All keywords must be 
written in lower-case characters, and they are not allowed to be used for other 
purposes (such as naming variables). 


auto 


double 

break 


else 

case 


enum 

char 


extern 

const 


float 

continue 


for 

default 


goto 

do 


if 


int 


struct 

long 


switch 

register 


typedef 

return 


union 

short 


unsigned 

signed 


void 

sizeof 


volatile 

static 


while 


Many C compilers add supplementary keywords to those defined in the ANSI 
specification in order to make best use of the features of the compiler or 
microcontroller. The terms listed below are also designated as keywords for the 
R8C family of microcontrollers. 


asm asm near 

far _Bool restrict 

near far inline 


elektor electronics 


7 












Constants and Variables 


Number systems 

The C language can work with several different number systems (number bases): 
decimal, octal, and hexadecimal. 

Numbers stated without any special identification (notation) are interpreted as 
decimal numbers by default. Numbers in all other number systems must be 
specially identified. Octal numbers begin with 0, hexadecimal numbers with Ox, 
and binary numbers with Ob. 


Base 

Notation 

Available characters 

Example 

Decimal(IO) 

- 

0123456789 

5 

Octal(8) 

0 ... 

01234567 

05 

Hexadecimal(16) 

Ox... 

01 23456789ABCDEF 

0x5 

Binary (2) 

Ob 

0 1 

Obi 11 10000 


The English (US) convention is always used for numerical notation. That means a 
full stop (‘period’) is used as the decimal marker for floating-point numbers. In C, 
the comma is used in as a separator in lists of numbers or variables. A colon 
marks a range of numbers. 


Examples: 



3 N 14159 


3,4 

3 and 4 

0:3 

0->3, thus 0, 1, 2, and 3 


Data types 

In C, the type of a variable must be declared before it can be used. Otherwise the 
compiler will not know how much memory to allocate for the variable. Basically, 
you should always select a type that is adequate for the intended purpose and 
requires the least amount of memory space. The most important data types are 
listed below. 


Type 

Memory space Value range 

_Bool 

8 

0 , 1 

char 

8 

0 -> +255 

signed char 

8 

-128 -> +127 

int, short 

16 

-32768 -> +32767 

unsigned int 

16 

0 -> +65535 

long 

32 

-2147483648 -> +2147483647 

float 

32 

-1.17..e-38F-> +3.4..e-38F 


8 


elektor electronics 






Examples: 

_Bool stop_button // button has only two states: on & off 
unsigned int _year // 0 -> 65535 sufficient for year numbers 
float _volume // floating-point number for calculations 


Constants 


Constants are numbers that cannot be changed in the program. That also includes 
all ‘normal’ numbers. Whole numbers (integers, or int ) are written without a 
decimal marker (decimal point). Floating-point numbers (float ) have a decimal 
point followed by additional digits. Characters (char ) are enclosed between 
single quotation marks ( ' ). Constants are declared using the #define 
keyword. 


#define <label> 


Examples: 


value 


No ; because this is 
only relevant for the 
compiler 


#define true 1 
#define false 0 
#define pi 3.14159 
#define letter_1 'A' 


// 1 = true 
// 0 = false 
// the factor □ 

// 'A' key on the keyboard 


The names of constants, variables and functions can be freely selected, but 
they are not allowed to contain any keywords or operator symbols. 
Basically, only the letters of the English alphabet, numerals and the 
underscore ( _ ) are used for names. You should chose names that give a 
good indication of the practical meaning of the constant. For instance, 
alarm_btn is much more meaningful than tl . 


Variables 

A variable is an item stored in memory that can be changed in the program. 
Variables can be numbers, letters, or text strings. In C, all variables must be 
declared before they can be used. Variables are considered to be ‘statements’, 
which means variable declarations must be terminated with a semicolon ( ; ). 
Variables are defined as follows: 

type <label> 

Examples: 

_Bool keypress ; 
long counter ; 

float radius ; 



; because this is a 
processor instruction 


elektor electronics 


9 



Variables are assigned values as follows: 


<label> 


value 



Examples: 
keypress = 1 ; 
keypress = false ; 
counter = 100 ; 


min_val = counter - 50 ; 
max_val = counter * counter ; 
_circum = radius * 2 * pi ; 



Commands and instructions for the processor, which are called 
‘statements’, are terminated with a semicolon ( ; ). 


10 


elektor electronics 






Operators in C 

Arithmetic operators 


The symbols for arithmetic operators in C correspond to the familiar symbols used 
on pocket calculators: 


+ addition 

// examples: 

y = x + 3 ; 

subtraction 

// 

y = X- b ; 

* multiplication 

// 

_Q 

* 

CO 

II 

/ division 

II 

Y = a/b ; 


The equal sign has a different meaning in C than in ordinary mathematics. In C, it 
is called the ‘assignment operator’. That means the expression to the right of the 
equal sign is computed and the result is assigned to the variable to the left of the 
equal sign. The following expressions are thus allowed in C, but not in normal 
mathematics: 


/ \ 

! 

)r 

X = x+y ; 
x = -x ; 


// compute x + y and store the result in x 
// change the sign of the variable x 


Relational operators 

Relational operators are used to compare variables. They return the result true 
or false , depending on the event. 


> 

greater than 

== equal 

>= 

greater tnan or equal 

!= not equal 

< 

less than 


<= 

less than or equal 



Logical operators 

The logical operators AND, OR and NOT can be used to execute the familiar 
operations of digital logic. 


b a 


AND 

a && b 

a || b 

OR 

!a 

NOT 

0 

0 

0 

0 

1 


0 

1 

0 

1 

0 


1 

0 

0 

1 

1 


1 

1 

1 

1 

0 



elektor electronics 


11 






Example: 

if(_price <= max_price && _account > 1 000) 

_buy(); 

/* The function _buy() will only be called if _price is less 
than or equal to max_price and _account contains more than 
1000 pounds 7 


The Renesas C compiler for the R8C has several additional logical operators that 
can be used for bitwise operations on variables: 


& 

for bitwise AND operations 

b a a A b 



0 0 0 

1 

for bitwise OR operations 

0 1 0 

1 0 0 

A 

for bitwise XOR operations 

1 1 1 


Examples: 


a =10011010 
b = 11000011 
a&b = 10000010 


a =10011010 
b = 11000011 
a|b = 11011011 


a =10011010 
b = 11000011 
a A b = 01011001 


Shortcuts 

Americans are masters at inventing shortcuts. That’s especially true for Dennis 
Ritchie and Brian Kernigham, the inventors of the C language. Many programmers 
type in their programs using the ‘hunt-and-peck’ system, so they try to avoid any 
unnecessary typing effort. 


Shortcut 

Normal 

Shortcut 

Normal 

a*=b 

a = a*b 

a«=b 

a = a<<b 

a/=b 

a = a/b 

a>>=b 

a = a>>b 

a+=b 

a = a+b 

a&=b 

a = a&b 

a-=b 

a = a-b 

a|=b 

a = a|b 

a%=b 

a = a%b 

XJ 

II 

< 

cc 

a = a A b 

a++ 

a = a+1 (increment) 


a- 

a = a-1 (decrement) 



Example: 

for(t=0, t<1 00000, t++); /* timer loop 7 


12 


elektor electronics 





Functions in C 

The function concept 

Functions are the essence of the C programming language. A function can be 
called from the main routine or from any other function. Every C program must 
include at least one function, which is called main() . It is automatically called 
when the program is started. 

Functions are individual program segments (blocks) that perform specific activities 
(operations), such as the familiar operations performed by pocket calculators: 

CE clears the input memory of a pocket calculator. In C, it would be described 
as a function that does not require any numerical input (parameters) and does not 
return any sort of number. 

expects to receive a number as input in order to calculate its inverse value. 
In C, this is described as a function with an input parameter. 

+ * / , by contrast, requires two parameters as input, and S , 

the summation function, requires several parameters. 

sin and log , on the other hand, are functions that require one input 
parameter. 


Declaring a function 
The general form of a C function is: 
type function_name(type varl.type var2,type var3,...) 


r \ 



return 

type 


input parameter with 
type declaration 


Examples: 

A function with no input or output parameters: 


void wait_1(void) 

asmfnop"); // Call no operation in assembly language 

The word void tells the compiler that the function wait_1 does not require any 
input parameters and does not return any result. The void keywords can also be 
omitted: 


wait_1 () 
asmfnop"); 



elektor electronics 


13 









If a function contains more than one instruction, the instructions must grouped into 
a block by enclosing them in curly brackets ( { } ). In that case the semicolon at 
the end must be omitted. 


wait_2() 

{ 


no 


asmfnop") 

asmfnop") 

asmfnop") 



no 


// Wait three times 


A function with an input parameter but no return parameters: 


int t; 

wait_3(int several_times) 
for(t=0;,t<= several_times;t++); 


/* The for loop increases the value of t stepwise 
(increments t) starting from 0 until it reaches the 
value of the input several_times (time delay) 7 


A function with input parameters and a return parameter: 


float _volume(float length, float width, float height) 
return length*width*height; 


/* This function expects three inputs, which are stored 
in the variables length, width and height. The product 
of these three variables is then calculated and returned 
to the caller as a floating-point number 7. 


Calling a function 

Functions are called by simply stating their names. This can be done at any 
location in the program. After the function has been processed, which can be 
recognised by the ; in case of a function containing only one instruction or the 
curly bracket } in case of a function containing several instructions, a return to the 
calling location occurs automatically. The keyword return has a different 
meaning in C than in assembly language. In C, it designates the return value 
instead of the end of a subroutine or function. 

Multiple-level function nesting is allowed. ‘Function nesting’ means that one 
function calls a second function, which in turn calls a third function, and so on. 


14 


elektor electronics 






Examples: 

Calling a function from the main routine without any input or return parameters: 

void main(void) 

{ 

wait_1(); 

} 


Calling a function from the main routine with an input parameter but no return 
parameters: 

void main(void); 

{ 

wait_3(100); 

} 

// The constant 100 is passed to function wait_3 


Calling a function from the main routine with input and return parameters: 


void main(void); 

{ 

no_of_litres = _volume(a,b,c); 

} 


/* The values of the variables a, b, and c are passed to the 
function _volume. The function then calculates the volume of 
a body and returns the result to the variable no_of_litres. 


elektor electronics 


15 






Program Control 
if 

It frequently happens that an instruction or block of instructions should only be 
executed if a certain condition is satisfied. A condition is satisfied if a test of the 
condition returns the value true . Every number except zero is regarded as 
true ; zero is regarded as false 



If several instructions are to be executed when the condition is satisfied, they must 
be grouped into a block. 


if (condition) 

{ 

statement_1 
state ment_2 
state ment_3 
II ... 




if(button == 3) 

redjed = _on; 


if(button == 3) 

{ 

grnjed = off; 

redjed = _on; 

} 


if.. .else 


If one instruction or block of instructions is to be executed when a condition is 
satisfied, while an another instruction of block of instructions is to be executed 
when the condition is not satisfied, an if... else conditional state men t is 


used. 

The general form is: 


if (condition) statement_1 ; else sfatement_2 ; 


sfatem 




If several instructions are to be executed, they must be grouped into a block. 


16 


elektor electronics 







Examples: 


if(button == 3) 

redjed = _on; 

else 

grnjed = _on; 


if(button == 3) 

{ 

grnjed = _off; 
redjed = _on; 

} 

else 

grnjed = _on; 


3 



if(button == 3) 

{ 

grnjed 

redjed 

} 

else 



off; 

on; 


grnjed = _on; 
redjed = _off; 


} 


switch 

If a conditional statement has more than one or two possible outcomes, it is very 
tedious to implement it using the if... else structure. In that case it’s better to 
use the switch /case structure with multiple alternatives. This type of program 
control can be compared to a rotary selector switch with multiple positions (cases). 

The general form is: 


switch (variable) 
{ 


case 

constant_1 ; 
instruction^ 
break; 

case 

constant_2; 

instruction_2 

break; 

case 

constant_3; 

instruction^ 

case 

II ... 
break; 

default 

instruction_x; 



The switch function compares the content of variable to the value of a 
constant (COnstant_x ) for each of the defined cases (case ). If the result of 
the comparison is positive, the corresponding instruction (instruction_x ) or 


elektor electronics 


17 








block of instructions is executed. Program control returns to the caller of the case 
statement when the break keyword is reached. If none of the cases listed in the 
case statement is found, the instruction following default is executed. The 
default portion can be omitted if it is not necessary. 


Example: 

switch (_button) 

{ 

case 1 : 

redjed = _on; 
break; 

case 2: 

yeljed = _on; 
break; 

case 3: 

grnjed = _on; 




} 


default blu_led=_on; 


may be 
omitted 




/* Enable the red LED if the value of _button = 1, the yellow 
LED if it is 2, and the green LED if it is 3. If the variable 
_button does not contain 1, 2, or 3 (e.g. 4), enable the blue 
LED 7 


for 

A for loop is used if part of a program must be executed multiple times. 
The general form is: 


for(start_value; end_condition; step_size) 
instruction^ ; 



When the for loop is called, start_value is assigned to a previously defined 
count variable. The count variable is then incremented or decremented by the 
value of step_size each time the loop is executed, until the test of 
end_COndition yields the logical value true . 

If several instructions are to be executed, curly brackets ( { } ) must be used to 
group them into a function block. 


18 


elektor electronics 




Examples: 


int t; 


for(t=0, t < 10, t++) 
blink_led(); 


/* Integer variable t is assigned the value 0 when the for 
loop is entered. Next, the function blink_led() is called. 
After the first pass through the loop, the variable t is 
incremented (t++) to the value 1 . As 1 is less than 10, the 
process continues until t = 9. The loop is thus executed ten 
times. 7 


a = 2; 
b = 10; 
c = 4; 

int i; 



count variable 


for(i = a; i < b; i+ = c) 

{ 

red Jed = _on; 
red Jed = _off; 

} 


/* This loop is executed only two times. 7 


while 

A while loop is used when execution is tied to a condition. 


The general form is: 

while(_condition) 

{ 

instruction^ ; 
instruction_2; 
II ... 





When the while loop is called, the value of the condition (_condition) is first 
tested. If the result is positive (true), the instructions (instruction_x ) are 
executed repeatedly until the result of the test is false. 


elektor electronics 


19 






Example: 


#define true 1 



while(i == true) 

{ 

i = button_pressed(); 
blink_led(); 


/* The function blinkjed is executed until the function 
button_pressed no longer returns the value 1 to variable i. 


do. ..while 

A while loop will not be executed if the condition is not satisfied at the 
beginning of the loop. If it is necessary for instructions to be executed at least 
once, the condition must be tested at the end instead. A do. ..while loop is 
used in such cases. 



Example: 

#define true 1 


do 

{ 

i = button_pressed(); 
blink_led(); 

} 

while(i == true); 

A — , 


/* The function blink led is executed at least once 7 


20 


elektor electronics 





Appendix 


Header file sfr_r813.h 

The header file sfr_r813.h provides access to the special function registers 
(SFRs) of the R8C microcontroller. These registers contain the basic settings for 
the microcontroller, such as the port directions (in/out), timer settings, A/D 
converter settings, UART settings, and so on. 

The R8C microcontroller has more than 50 SFRs. That means we have to limit 
ourselves here to a selection of the most important SFRs. Refer to the R8C/13 
Group Hardware Manualor detailed information on all of the SFRs. 


Port registers (P0, PI, P2, P3 and P4) 

A port is a memory location that is connected to the pins of the microcontroller and 
is thus externally accessible. Ports are used for inputting and outputting data. A 
port can be either an input or an output. When the microcontroller is started up, all 
ports are configured as inputs by default. The direction (input or output) can be 
changed using the Port Direction (PD) registers. 

The following example shows how to change the port direction: 

Examples: 
pdl = OxOF; 

)* portl , bits 0:3 = output 
bits 4:7 = input 7 

pd2_3 = 1 ; 

/* port2,bit3 = output 7 


pfrrl Oredwt RBgiSlW pdl 

<■0. l-i3LJ 


*7 bd fcfli&a b2 bl bti 


d |d |d b I,* |d |d | d 


3-5 nfeji &r1 hfl>/ 


... and the following example shows how to output data via a port: 


Pori Hogwtorek 

1 

I-*. 1 2 1. * 

bl b6 b5 M 

b3 b2 M bO 

1 

■ i ij Li [-M 

9 d U * 1 

1 



Examples: 

pi = OxOF; 

/* portl, bits 0:3 = 1 
bits 4:7 = 07 


pd2_3 = 0; 

/* port2,bit3 = 07 


/* If a 1 is written to a port register, the supply voltage (e.g., 

+5 V) will be present on the corresponding pin. A 0 causes the pin 
to be at ground potential (0 V) 7 


elektor electronics 


21 





Protection registers (PRCR) 

The PRCR registers can be used to protect the contents of other important 
registers against overwriting (if the program goes out of control, for instance). 


P rowel Register PRCft Examples: 

prcO = 1 ; 



System Clock Control registers (CM1, CM2 and OSD) 

The R8C microcontroller has two oscillators to provide the clock for the CPU. One 
oscillator is internal and is called ‘on-chip oscillator’, while the other is external and 
is called ‘main clock’. The ‘main clock’ oscillator uses a quartz crystal connected to 
the Xin and Xout pins. 

The CM registers determine how the microcontroller clock signal is generated. In 
addition, a prescaler can be enabled and configured to reduce the frequency of the 
processor clock. 


System Qodk Control Register 
CMi 


b7 

b& 

b5 

b-4 

bi m 

::n 


1 ° 

_eJ 

3 


jiL 

c 

c 


external crystal 
oscillator mode 



Examples: 
cm13 = 1; 

/* Xin/Xout on ports p46 and p47 
= ext. xtal 7 

cm15 = 1; 

/* Xin/Xout driver high 7 
cm16 = 0; 

/* prescaler for CPU clock 7 
cm17 = 0; 

/* prescaler for CPU clock 7 


Sy&ienn ciosh CoiMral H&p&le' 
CMD 


b7 m tin- t>a , b2 bs K! 



Examples: 
cm05 = 0; 

/* enable Xin/Xout on ports p4.6 
and p4.7 7 

cm06 = 0; 

/* enable prescaler 7 


CM1 prescaler 
bits 6 & 7 set 


cyrstal oscillator enabled 


22 


elektor electronics 



The Oscillator Stop Detection (OSD) register is used together with the other 
registers to select the clock source, and it is also responsible for monitoring the 
clock signal. 


Obciiiaidf Stop Detection 
OSD 



Examples: 
osd2 = 0; 

/* enable external xtal osc. as 
CPU clock source 7 

osd2 = 1; 

/* disable external xtal osc. 7 


Header file math.h 

The header file math.h contains the library of mathematical functions for the 
R8C. Here we describe some of the most important functions. 


Functions of type double Functions of type float 

f_name(double x); f_name(float x); 


sin(); 

sqrt(); 


sinf(); 


sqrtf(); 

cos(); 



cosf(); 


powf(); 

tan(); 

exp(); 


tanf(); 




log(); 




expf(); 

asin(); 

Iog10(); 


asinf(); 


logf(); 

acos(); 



acosf(); 


log 1 0f(); 

atan(); 

mod(); 


atanf(); 



sinh(); 

fabs(); 


sinhf(); 


fabsf(); 

cosh(); 

floor(); 


coshf(); 


floorf(); 

tanh(); 

ceil(); 


tanhf(); 


ceilf(); 


Functions of type double 
f_name(double x, double y); 

Functions of type float 
f_name(float x, float y); 

powf(); 
atan2f(); 
fmodf(); 


pow(); 

fmod(); 

atan2(); 

fmod(); 


elektor electronics 


23 












lectronics 


Microcontroller 

Basics 

Microcontrollers make things 
possible that vastly exceed 
what could be done previous- 
ly. Innumerable applications 
show that almost nothing is 
impossible. There’s thus 
every reason to learn more 
about them, but that raises 
the question of where to 
find a good introduction to 
this fascinating technology. 
This book clearly explains 
the technology using various 
microcontroller circuits and 
programs written in several 
different programming 
languages. In the course 
of the book, the reader 
gradually develops increased 
competence in converting 
his or her ideas into micro- 
controller circuitry. 


Microcontroller 

Basics 



ISBN 0-905705-67-X 
230 Pages 
£18.70 (US$ 33.70) 


Elektor Electronics 
(Publishing) 

Regus Brentford 
1000 Great West Road 
Brentford TW8 9HH 
United Kingdom 


Tel. +44 (0) 208 261 4509 
Fax +44 (0) 208 261 4447 


More information on www.elektor-electronics.co.uk